BFCM 2025 Checklist: An Early Starter Preparation Guide for Merchants
Tariffs. AI-driven marketplace algorithms. The repeal of de minimis. And ad costs rise Y-O-Y. For
Magento has introduced a new feature called Declarative Schema which aims to simplify the Magento installation and upgrade processes. This new concept will allow a developer to get away from writing updates for each new version in favour of declaring the final result that the developer wants to achieve.
To achieve the final result developers need to add, rename then change the type of the column in order to get the final result, which was not efficient and also time-consuming.
The new declarative schema approach allows developers to declare the final desired state of the database and has the system adjust to it automatically, without performing redundant operations. Developers are no longer forced to write scripts for each new version. In addition, this approach allows data to be deleted when a module is uninstalled.
In this blog, we will only discuss file required for a Declarative Schema.
You can check our complete module here and you can also modify it according to your need.
Firstly create a file “db_schema.xml” inside folder “Ced/GraphQl/etc” and write the following code
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="author_data" resource="default" engine="innodb" comment="Author Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="Author ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="255" comment="Author Name"/>
<column xsi:type="varchar" name="author_email" nullable="false" length="255" comment="Author Email"/>
<column xsi:type="varchar" name="affliation" nullable="false" length="255" comment="Affliation"/>
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
Each table node represents a table in the database.
A table node can contain three types of subnodes:
The column subnode defines a column in a table. Each column requires its own declaration.
So when you run setup:upgrade command then it will create the table “author_data.”
If you want to add a new column to the existing table then you need to add a new column node in db_schema.xml and on running upgrade command it will add the new column.
Now if you want to remove the existing column then you either need to remove the column node (<column>) inside the table node or you can set disabled attribute to true.
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age" disabled=”true” />
But before running the upgrade command you need to add your schema to db_whitelist_schema.json file by running the following command-
php bin/magento setup:db-declaration:generate-whitelist --module-name=Ced_GraphQl
Ced_GraphQL is a module name. You need to specify your module name there.
Now on running setup:upgrade command it will remove the column.
You can change the column type, changing its type attribute to int, varchar, text etc.
To rename a column you need to first remove the one you don’t want and add another column with your desired name. Now you need to migrate that column data into a newly created one, to do this you need to set an attribute on Create which will migrate data from the old column.
If we want to rename the author_email column to just email, we will remove the author column and add a new one.
<column xsi:type="varchar" name="email" onCreate="migrateDataFrom(author_email)" on_update="false" nullable="false" default="" comment="Author Email"/>
So this will create new column ‘email’ with data from the removed column.
To drop a table, either remove the entire table node from db_schema.xml or set disabled attribute to true.
Insert Default data to table at the time of installation.
Since in the old method, we used to write scripts in Install Schema or Upgrade schema when a table was created, but now in the new version, this will be done through Patch system.
A data patch is a class that contains data modification instructions. It is defined in a <Namespace>/<Module_Name>/Setup/Patch/Data/<Patch_Name>.php file and implements \Magento\Setup\Model\Patch\DataPatchInterface.
A schema patch contains custom schema modification instructions. These modifications can be complex.
It is defined in a<Vendor>/<Module_Name>/Setup/Patch/Schema/<Patch_Name>.php file and implements \Magento\Setup\Model\Patch\SchemaPatchInterface.
So to add data to the author table create AddData.php file inside folder Ced/GraphQl/Setup/Patch/Data and write the following code
<?php
namespace Ced\GraphQl\Setup\Patch\Data;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
use Magento\Framework\Module\Setup\Migration;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* Class AddData
* @package Ced\GraphQl\Setup\Patch\Data
*/
class AddData implements DataPatchInterface, PatchVersionInterface
{
/**
* @var \Ced\GraphQl\Model\Author
*/
private $author;
/**
*
* @param \Ced\GraphQl\Model\Author $author
*/
public function __construct(
\Ced\GraphQl\Model\Author $author
) {
$this->author = $author;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function apply()
{
$authorData = [];
$authorData['author_name'] = "Andrew Tye";
$authorData['author_email'] = "andrew@email.com";
$authorData['affliation'] = "Andrew Company";
$authorData['age'] = 32;
$this->author->addData($authorData);
$this->author->getResource()->save($this->author);
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [];
}
/**
* {@inheritdoc}
*/
public static function getVersion()
{
return '2.0.0';
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}
Now on running the upgrade command, it will add data to author_table. Patch is only one-time run and you will find a list of patch in patch_list table. You can use our module to make changes in the declarative schema.
That’s it for the Declarative Schema from our end. Since official Magento 2.3 version is yet to be released, so whatever we have described to you here is based on Magento 2.3 beta version.
We have made changes to our GraphQL Module mentioned in our previous blog itself. You can check and implement the changes which we have described here.
Tariffs. AI-driven marketplace algorithms. The repeal of de minimis. And ad costs rise Y-O-Y. For
What’s Changing Beginning September 1, 2025, TikTok Shop will require all advertisers to run promotions
Amazon is making one of the biggest catalog cleanups in recent memory. Starting September 2,
Amazon Business is marking its 10th anniversary in 2025, celebrating a decade of transforming business
Best Buy has entered the growing “marketplace-as-a-service” trend by launching its first U.S. online marketplace
Etsy is experimenting with a new tiered ad strategy for sellers—currently in beta—that requires a
As announced, Amazon has officially opened submissions for its Prime Big Deal Days (October) and
Amazon is making grocery delivery more convenient than ever for its Prime members. As of
TikTok is no longer just shaping shopping trends—it’s now building the infrastructure to deliver them.
As eBay celebrates its 30th anniversary, the marketplace is doubling down on artificial intelligence to
eCommerce sellers, and those selling on Amazon, are entering a critical pre-Black Friday Cyber Monday
Germany’s eCommerce heavyweight Kaufland officially launched its online marketplace in France, marking its sixth market
Shein’s UK arm posted pre-tax profits of £38.2 million in 2024—an eye-catching 56.5% increase—as revenues
UPS will align its dimensional weight (DIM) calculation method with FedEx starting August 18, 2025,
Release Highlights WooCommerce’s latest updates bring WCAG 2.2 compliance, shareable checkout URLs, and faster, more
The global pet care market is booming, with projections estimating it will hit $236.1 billion
The U.S. will end the de minimis exemption—the rule that allowed packages under $800 to
Etsy is increasingly shifting from keyword-based search to a fully personalized, AI-powered shopping experience. During
TikTok Shop is updating its measurement of seller communication, effective mid-2025, shifting from a 24-hour
Walmart Marketplace sellers must migrate from Item Spec 4.x to Item Spec 5.0 (OmniSpec 5)