Questions tagged [declarative-schema]

Declarative setup is based on database structure declarations, and is used in projects such as Doctrine. Schema files declare what the database structure should be, and Magento determines the differences between the current table structure and what it should be. These differences can be represented with atomic SQL operations.

Filter by
Sorted by
Tagged with
3
votes
1answer
66 views

Database schema related change reverted

I have one of my Magento 2 projects running with version 2.3.3. There are so many simple products for one single configurable product and as a result, there is an issue with the length of the SKU. To ...
0
votes
2answers
242 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" ...
0
votes
0answers
25 views

Magento 2 - Order Scalar Extension Attributes - Where to store

I need to store few disjoint scalar custom information on a completed sales Order in Magento 2 and display them in a completed Sales order detail view in the Magento admin and also in the Sales order ...
0
votes
4answers
260 views

Magento 2.3.3 declarative schema column type json

I want to create One table model using declarative schema having one column type as json. <?xml version="1.0" ?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
0answers
73 views

How to define a dependency between data patch and upgrade script

As described in the DevDocs you can define data patch dependencies. To define a dependency in a patch, add the method public static function getDependencies() to the patch class and return the ...
0
votes
0answers
53 views

How to change quote table customer_note column type to text

I tried to update the quote table customer_note column type to text using setup script and schema patch. Column type updated after run setup:upgrade but when I run setup:upgrade the second time then ...
0
votes
2answers
489 views

Magento2.3 - How to set text column table value default is None using declarative schema?

I want to create a custom table using db_schema.xml like that contains column like this: I tried to do it like this: <column name="description" nullable="false" default="null" xsi:type="text"/>...
0
votes
0answers
92 views

How to create a custom table in Magento 2.3 using XML (Declarative Schema) and integrate in custom admin grid?

I need to create an admin grid and for that i need to create a custom table using Declarative Schema in Magento 2.3. How to create a custom table using declarative schema and integrate the table with ...
0
votes
0answers
26 views

How to validate declarative schema

In Firstname i don't want to insert special character and in email only insert valid email id <table name="feedback" resource="default" engine="innodb" comment="mage2 tv example brand table" ...
3
votes
0answers
193 views

Magento 2.3 - Add a new column after one column into the table using db schema

I need to add a new column after one of the particular columns in the existing table using DB schema & checked this dev doc link, they didn't mention about the before or after column. Is there ...
3
votes
1answer
773 views

Magento 2.3 : Remove Constraint from db_schema.xml file

I just try to override db_schema.xml file of a core customer module into my custom module , but there is no success. I need to remove a constraint defined in customer db_schema.xml file, how may I do ...
0
votes
2answers
136 views

How to use magento declarative schema?

How to create table,alter table and drop the table using declarative schema?? If anyone have reference links or extension then please guide me. I already referred below links. inchoo Blog ...
0
votes
1answer
377 views

Renaming identity column with declarative schema leads to SQL error

I have the following db_schema.xml: <?xml version="1.0"?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/...
5
votes
0answers
788 views

setup:db:status still reports “Declarative Schema is not up to date” after update

Since an update to Magento 2.3 I am experiencing the following issue: bin/magento setup:db:status Declarative Schema is not up to date Run setup:upgrade to update your DB schema and data. Although ...
2
votes
3answers
430 views

How to change eav_attribute table's note column's datatype varchar to mediumtext using declarative schema?

I have follow this documnet https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/db-schema.html but not get success module.xml <?xml version="1.0"?> &...
2
votes
1answer
138 views

How to rename third-party table from our module in Declarative Schema in Magento 2.3.0?

I wanted to rename table ThirdParty to NewTable So I wrote the following code: <?xml version="1.0" ?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0
votes
2answers
2k views

Magento 2.3.1 : Add addition column in sales_order table using db_schema

How to add addition column in sales_order table using db_schema or in Magento2.3.1 best way?
1
vote
3answers
520 views

Magento 2.3.2: How to delete custom table column

I have created Custom Table Using below code. Table has been created successfully with columns. <?xml version="1.0"?> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
1
vote
1answer
43 views

Magento 2: Can we create a product attribute without patch with the declarative schema?

I want to create a product attribute without patch with the declarative schema. Example would be more descriptive.
2
votes
1answer
625 views

How to convert install/upgrade schema scripts to db_schema.xml files?

I'm following the guide from Magento DevDocs about the Declarative Schema I created a new module with old setup way (InstallSchema.php, InstallData.php) to test the convert install/upgrade schema ...
3
votes
1answer
3k views

Error: DDL statements are not allowed in transactions while running setup:upgrade. Running Data Patch

Magento 2.3.1 After making the data patch @ following location vendor/ModuleName/Setup/Patch/Data/AddMyColumnPatch.php code given below for AddMyColumnPatch.php. When I run bin/magento setup:...
0
votes
2answers
871 views

Magento 2. Declarative Schema. How to uninstall a patch without uninstalling the module?

The official docs say this. Revertable data patch - A patch that can be reverted as a module or patch is uninstalled or deleted. I know that Revertable patches must implement Magento\Framework\...
3
votes
1answer
68 views

Magento 2. Declarative schema. What is the use of the memory engine?

When creating tables using the Declarative Schema one can set the engine="" attribute value as memory. I can't seem to find an example in the core. What is a use-case for this configuration, how does ...
1
vote
1answer
243 views

Declarative schema: Incorrect Foreign Key Diff

We created a new table using M2's declarative scheme like this: <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/...
8
votes
2answers
2k views

setup:upgrade SQL error after update from 2.2.8 to 2.3.1

What could be the reason for this error on bin/magento setup:upgrade after updating from 2.2.8 to 2.3.1? SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name '...
0
votes
1answer
343 views

Magento 2.3 - How add new column/field to sales_shipment table

I need to add a new column/field (total_volume) to sales_shipment table. I know that I can use two approaches to do this, but what is the best? The first approach is to use the "Extension Attributes"....
2
votes
3answers
2k views

How to add foreign key in db_schema.xml

I'm using magento 2.3 to create a custom module, i tried to create database tables for my custom module in etc/db_schema.xml like this: <table comment="province Table" engine="innodb" name="...
1
vote
2answers
847 views

When updating to Magento 2.3.1 db_schema.xml is invalid: Element 'schema': No matching global declaration available for the validation root

While updating Magento 2.2.8 to 2.3.1 I'm facing issue when running bin/magento setup:upgrade I get error: The XML in file "/var/www/html/vendor/magento/module-store/etc/db_schema.xml" is invalid:...
0
votes
2answers
332 views

Migrate to declarative schema

people. I'm trying to migrate to declarative schema on my module with magento v2.3.1. But when i'm running php bin/magento setup:install --convert-old-scripts=1 it doesn't generates any db_schema.xml. ...
0
votes
1answer
54 views

Declarative schema approach to make customer's lastname optional

With pre-2.3 Magento versions we were able to write UpgradeData code and make customer's lastname optional as mentioned here: Magento 2 : How to make “lastname ” optional in customer registration form?...
6
votes
2answers
505 views

Empty Collection :: CollectionFactory Approach and getCollection approach both give empty result

Magento 2.3.1 Php7.2 Ubuntu 18.04 I have created a table in my database using db_schema.xml and then populated that table with sql insert commands directly in mysql workbench. My model code is &...
2
votes
2answers
135 views

Magento 2.3 What are the profits of using db_schema.xml instead of using setup script?

Magento 2.3 used db_schema.xml instead of setup script. What are the benefits of using db_schema.xml over setup script?
3
votes
3answers
4k views

Magento 2.3 - How to add custom column to customer_entity table

I'm creating a Referral Program module, and I want to create a custom column inside the customer_entity table. The column is referred_by and it's a foreign key that as a relation with the ...
2
votes
1answer
668 views

Drop column on declarative schema not working as expected

I was playing on Magento 2.3 with Declarative Schema, and everything works very well when I added a new column do db_schema.xml and did a setup:upgrade. However, when removing a column node from XML ...
2
votes
1answer
145 views

Add new Order Statuses to Magento 2.3 using declarative scheme approach

I need to add several order statuses. Could not found info how to implement it via Data Patches
4
votes
2answers
4k views

Magento 2.3 : How to create product attribute via declarative schema?

How to create a product attribute in Magento 2.3 via declarative schema. I have tried below code but the input element is not visible on the form. <?php namespace Rokanthemes\Updates\Setup\Patch\...
1
vote
1answer
159 views

Magento 2.3 - Need detail about some newly introduced feature

I need to know about some of the newly introduced featured of Magento 2.3 GraphQL Declarative DB Schema Asynchronous and Bulk Web API There are few blogs information but not elaborating properly. I ...
8
votes
2answers
6k views

Magento 2.3 use of `db_schema_whitelist.json` file in etc directory of each module

What is the use of db_schema_whitelist.json located in Magento Catalog etc directory? In Magento 2.3 version, I found db_schema_whitelist.json and db_schema.xml files, in the Magento_Catalog module. ...
4
votes
0answers
98 views

Uninstalling extension

Up to versions 2.2 (including it) you could uninstall modules installed via composer and when you did that the method uninstall from Setup/Uninstall.php will be executed. Basically this was the place ...