People who code: we want your input. Take the Survey
6

Create file db_schema.xml app/code/VendoreName/ModuleName/etc db_schema.xml <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> <table name="declarative_table"> <column xsi:type="int" name="id_column" padding=...


3

It can be achieved using DataPatchInterface namespace Vendor_Name\Module_Name\Setup\Patch\Data; use Magento\Customer\Setup\CustomerSetupFactory; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\DataPatchInterface; use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory; class BuiltEav ...


3

You need to use data patch (DataPatchInterface), instead of db-schmena, Db-scheme basically used for database table create, table structure changes. An example: <?php namespace Devbera\ExamWork\Setup\Patch\Data; use Magento\Framework\Setup\Patch\DataPatchInterface; use Magento\Framework\Setup\Patch\PatchInterface; use Magento\Framework\Setup\Patch\...


3

You can use the below code in your module's Setup/InstallData.php <?php namespace Vendor\CustomerAttribute\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Customer\Model\Customer; use Magento\Customer\Setup\CustomerSetupFactory; ...


2

Declarative schema makes it easy to install and update Magento versions. Prior to now, each time developers needed to compose database scripts in PHP for the new version of Magento. For example, in the current version of Magento, you can change the pattern of a Magento database by composing code with UpgradeSchema and InstallSchema. However, with the new ...


2

<table comment="my table comment" engine="innodb" name="my_table_name" resource="default"> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="...


1

try this $installer->getConnection()->addColumn( $installer->getTable('sales_order'), 'req_desc', [ 'type' => 'text', '2M', 'nullable' => true, 'comment' => 'Pakke Shipment Label', ] );


1

$installer->getConnection()->addColumn( $installer->getTable('sales_order'), 'pakke_label', [ 'type' => 'text', 100, 'nullable' => true, 'comment' => 'Pakke Shipment Label', ] ); Use your suitable value in place of "...


1

try this <table name="custom_table" resource="default" engine="innodb" comment="Custom Table"> <column xsi:type="int" name="entity_id" unsigned="true" nullable="false" padding="10" identity="true" comment="Entity Id"/> <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint&...


1

Eventually, I found out. Please see: <column name="created_at" nullable="false" xsi:type="datetime" default="CURRENT_TIMESTAMP" on_update="false"/> <column name="updated_at" nullable="true" xsi:type="datetime" default="CURRENT_TIMESTAMP" on_update="true"/> I needed to add this part: default="CURRENT_TIMESTAMP"


Only top voted, non community-wiki answers of a minimum length are eligible