Skip to main content

Questions tagged [db-schema]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5 votes
1 answer
4k views

Magento 2.4 Error: The attribute 'length' is not allowed

I want to change the field type of catalogrule_product table from varchar to text. <column xsi:type="varchar" name="action_operator" nullable="true" length="10&...
VIPIN A ROY's user avatar
4 votes
1 answer
1k views

db_schema.xml setup:db-declaration:generate-whitelist: Constraints/index changes are not applied/refreshed - (Is there cached db_schema.xml?)

Magento 2.3 Question Is there any place where db_schema.xml for your module is cached/restored from? Issue I need to refresh/get the recently changed db_schema.xml changes to apply, which is not ...
CvRChameleon's user avatar
3 votes
2 answers
5k views

Created at and Updated at columns using db schema xml - Magento 2

I have a custom table. Using the InstallSchema, I was able to add default values using: )->addColumn( 'created_at', \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, null, ['...
Attila Naghi's user avatar
  • 4,023
2 votes
2 answers
16k views

How to create table and field using db_schema.xml in magento 2

I want to create table and fields using db_schema.xml rather than InstallSchema in custom module. Can anyone help please?
Naresh Sharma's user avatar
2 votes
3 answers
3k views

add custom attribute for customer in magento 2.3 using db schema

how I can add a custom attribute for customer using DB schema in Magento 2.3 does anyone is already tried Just help me?
prabhakaran7's user avatar
  • 1,087
2 votes
1 answer
288 views

Magento 2: How to increase the column max length?

I want to increase the customer firstname max length so I have updated the length of that column using my custom module dbschema.xml. After updating the length, I can see the updated length in ...
MagentoDev's user avatar
2 votes
1 answer
823 views

database schema vs schema patch in magento 2

I have doubts about the database schema and schema patch so can anyone help me to understand the difference between
Kushal Dani's user avatar
  • 2,114
1 vote
2 answers
5k views

Auto increment in db_schema.xml

In M2 dev docs there is this regarding auto increment: identity Indicates whether a column is auto incremented. Here's excerpt from my db_schema.xml: <column xsi:type="int" name="entity_id" ...
Vadim Shmyrov's user avatar
1 vote
2 answers
496 views

Magento2.3 - What is the benefit of Declarative DB Schema over Traditional installation schema for DB management?

At the Magento Imagine Conference, Magento announced the next noteworthy release on the Magento platform – Magento 2.3. It has enormous features, back-end enhancements, and optimizations. So I just ...
user avatar
1 vote
1 answer
1k views

Can't create unique and fulltext index on the same column

My table in db_schema looks like below. <table name="test"> <column xsi:type="int" identity="true" name="test_id" padding="10" unsigned="true" nullable="false" comment="Entity Id"/> ...
zsDev's user avatar
  • 11
1 vote
2 answers
872 views

How to force my db_schema.xml to run after a third-party InstallData.php?

I'm working with a legacy module where they used the old InstallData.php script to build their tables, and now I need to make some changes to them. If I wrote those changes in a db_schema.xml, it gets ...
Ivan Augusto's user avatar
1 vote
3 answers
1k views

Declare length of int column in db schema

How to declare int length in Magento 2.4 db_schema file?
Vamsi Krishna's user avatar
1 vote
1 answer
495 views

can not create db_schema_whitelist.json file in magento 2.4.4

I have issue to create custom mysql table from xml schema. i have create app/code/Vendor_Name/Module_Name/etc/db_schema.xml db_schema.xml <?xml version="1.0"?> <schema xmlns:xsi=&...
ketty's user avatar
  • 107
1 vote
4 answers
897 views

How to change table column nullable definition using declarative schema?

I have added a table using declarative schema given below: <table name="trade_item_brand_category"> <column xsi:type="int" name="id" padding="10&...
amitshree's user avatar
  • 7,036
1 vote
0 answers
18 views

After new compilation , my custom module's table data was reset in magento 2?

I have a custom module with the custom table, When i am doing compilation in some time the table data was completely removing and only the empty data base table is exist. I created this table using ...
Mujahidh's user avatar
  • 2,813
1 vote
1 answer
101 views

Custom order Status on Magento 2 programmatically

I have built a Payment Module and I want to add some custom status on table sales_order_status using etc/db_schema.xml. Is this possible? Thank you.
phpDev's user avatar
  • 11
0 votes
2 answers
2k views

Magento 2 how to increase text type field length?

I have a module where I save a PDF file in a text type field, however I just realized that the pdf was not stored completly, it misses some characters. This is how I created the field: $installer->...
Oscar Vazquez's user avatar
0 votes
2 answers
360 views

char column in db_schema.xml

https://developer.adobe.com/commerce/php/development/components/declarative-schema/configuration/#column-subnode I didn't find the char type (only varchar) in the column section but in the length ...
Ilja Polanskis's user avatar
0 votes
1 answer
2k views

Magento 2.3 How can add primary key constraint combination of multiple column using db_schema.xml?

There are some custom tables in the database which don't have a primary key. A single column can not be a primary key. So I want to make a primary key with the help of existing two-column combinations....
Vinod Kumar's user avatar
  • 2,065
0 votes
2 answers
248 views

Is there any way to update installschema.php to dbschema.xml?

How to create dbschema.xml from installschema.php
user12's user avatar
  • 1
0 votes
1 answer
64 views

How to add new Foriegn Key in existing table in Magento 2.4.5

I am trying to add a new foriegn key in existing table using db_schema.xml but it is not working at all I tried to delete the table and delete module from setup_module table as well but still nothing ...
Syed Hassan Zamir's user avatar
0 votes
1 answer
360 views

How to make id field auto increment in db_schema.xml in mageno 2.4?

I have a custom table created through db_schema.xml (code below): <?xml version="1.0"?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
LosMos's user avatar
  • 121
0 votes
1 answer
824 views

Magento 2 - can't add foreign key constraint with declarative schema (db_schema.xml) - Reference column X in reference table Y do not have index

I try to add this table: MODULE/etc/db_schema.xml: <?xml version="1.0"?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="...
Black's user avatar
  • 3,380
0 votes
1 answer
314 views

setup:db-declaration:generate-whitelist does nothing - no results or errors

M2.4.3-p1. Trying to use db_schema.xml as that appears to be the way forward. setup:upgrade is not adding my tables. setup:db-declaration:generate-whitelist is not generating the whitelist. Basically ...
Adam Lavery's user avatar
0 votes
1 answer
703 views

foreign key db_schema.xml automatic renamed to FK_ magento 2

I have this db_schema.xml <?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <schema xmlns:xsi=&...
fudu's user avatar
  • 1,288
0 votes
1 answer
1k views

Magento 2 - create a table with foreign key constraint

I try to add this database table. It has a foreign key constraint to the customer_entity table. I need to configure it so if the customer is getting deleted that record is also getting deleted. This ...
Black's user avatar
  • 3,380
0 votes
1 answer
452 views

Magento2: what is the purpose of having db_schema_whitelist.json?

I'm looking for some sort of explanation for the below topics but I'm not able to find the exact answers on the internet. What is the need for db_schema_whitelist.json? (I have read that this file ...
MagentoDev's user avatar
0 votes
1 answer
342 views

How to filter products out with custom created field on catalog_product_entity

I have added 2 fields in db_schema.xml there created on table catalog_product_entity the challenges for me now are I'm using the one field as custom state and this state is the field I need to filter ...
ParisNakitaKejser's user avatar
0 votes
1 answer
493 views

How to update Magento core column from type int to decimal using declarative schema?

I want to update the core table column from type int to decimal. <column xsi:type="int" name="column_name" padding="10" unsigned="true" nullable="false&...
Sri's user avatar
  • 1
0 votes
1 answer
332 views

Change type of field in db (table: quote, field: customer_note, current type: varchar, wanted type: text)

I try to change the type of the field customer_note in the quote table from varchar to text. I went the declarative way: VendorName/Module/etc/db_schema.xml: <?xml version="1.0" ?> <...
Hawkeye_00's user avatar
0 votes
1 answer
56 views

Unable to create table with foreign key?

<table name="profile_products" resource="default" engine="innodb" comment="profile products"> <column xsi:type="smallint" ...
bagish's user avatar
  • 1
0 votes
1 answer
266 views

Base DB schema didn't create table

In my report_sales > coupons page I get exception Base table or view not found: 1146 Table salesrule_coupon_aggregated doesn't exist And I find out that system didn't create this table (It doesn't ...
Mikhaylo HODOVANIUK's user avatar
0 votes
1 answer
1k views

How to add created at and updated at column and update it on values save?

I want to add created_at and updated_at columns in a custom table and update both columns on saving the data.
Kazim Noorani's user avatar
0 votes
1 answer
945 views

Allow tinytext in db_schema.xml magento 2

I'm doing a custom migration from Magento 1.9 to Magento 2.3.4 , in one of the custom module on Magento 1.9 it uses tinytext as table column type, therefore I tried to recreate this module using ...
jojo's user avatar
  • 39