@@ -23,10 +23,10 @@ The following example, extracted from the `Catalog/etc/db_schema.xml` file, defi
23
23
``` xml
24
24
<table name =" catalog_product_entity_datetime" resource =" default" engine =" innodb"
25
25
comment =" Catalog Product Datetime Attribute Backend Table" >
26
- <column xsi : type =" int" name =" value_id" padding = " 11 " unsigned =" false" nullable =" false" identity =" true" comment =" Value ID" />
27
- <column xsi : type =" smallint" name =" attribute_id" padding = " 5 " unsigned =" true" nullable =" false" identity =" false" default =" 0" comment =" Attribute ID" />
28
- <column xsi : type =" smallint" name =" store_id" padding = " 5 " unsigned =" true" nullable =" false" identity =" false" default =" 0" comment =" Store ID" />
29
- <column xsi : type =" int" name =" entity_id" padding = " 10 " unsigned =" true" nullable =" false" identity =" false" default =" 0" comment =" Entity ID" />
26
+ <column xsi : type =" int" name =" value_id" unsigned =" false" nullable =" false" identity =" true" comment =" Value ID" />
27
+ <column xsi : type =" smallint" name =" attribute_id" unsigned =" true" nullable =" false" identity =" false" default =" 0" comment =" Attribute ID" />
28
+ <column xsi : type =" smallint" name =" store_id" unsigned =" true" nullable =" false" identity =" false" default =" 0" comment =" Store ID" />
29
+ <column xsi : type =" int" name =" entity_id" unsigned =" true" nullable =" false" identity =" false" default =" 0" comment =" Entity ID" />
30
30
<column xsi : type =" datetime" name =" value" on_update =" false" nullable =" true" comment =" Value" />
31
31
<constraint xsi : type =" primary" referenceId =" PRIMARY" >
32
32
<column name =" value_id" />
@@ -160,7 +160,7 @@ For more information about each type, refer to the annotations in the correspond
160
160
Example:
161
161
162
162
``` xml
163
- <column xsi : type =" int" name =" entity_id" padding = " 10 " unsigned =" true" nullable =" false" identity =" true" comment =" Credit ID" />
163
+ <column xsi : type =" int" name =" entity_id" unsigned =" true" nullable =" false" identity =" true" comment =" Credit ID" />
164
164
```
165
165
166
166
#### ` constraint ` subnode
@@ -230,10 +230,10 @@ The following example creates the `declarative_table` table with four columns. T
230
230
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
231
231
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
232
232
+ <table name="declarative_table">
233
- + <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
234
- + <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
233
+ + <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
234
+ + <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
235
235
+ <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
236
- + <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
236
+ + <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
237
237
+ <constraint xsi:type="primary" referenceId="PRIMARY">
238
238
+ <column name="id_column"/>
239
239
+ </constraint>
@@ -252,10 +252,10 @@ In the following example, the `declarative_table` table was completely removed f
252
252
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
253
253
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
254
254
- <table name="declarative_table">
255
- - <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
256
- - <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
255
+ - <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
256
+ - <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
257
257
- <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
258
- - <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
258
+ - <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
259
259
- <constraint xsi:type="primary" referenceId="PRIMARY">
260
260
- <column name="id_column"/>
261
261
- </constraint>
@@ -285,10 +285,10 @@ This declarative process of renaming a table is not fast. If you need to migrate
285
285
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
286
286
+ <table name="new_declarative_table" onCreate="migrateDataFromAnotherTable(declarative_table)">
287
287
- <table name="declarative_table">
288
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
289
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
288
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
289
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
290
290
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
291
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
291
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
292
292
<constraint xsi:type="primary" referenceId="PRIMARY">
293
293
<column name="id_column"/>
294
294
</constraint>
@@ -307,11 +307,11 @@ The following example adds the `date_closed` column.
307
307
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
308
308
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
309
309
<table name="declarative_table">
310
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
311
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
310
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
311
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
312
312
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
313
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
314
- + <column xsi:type="timestamp" name="date_closed" padding="10" comment="Time of event"/>
313
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
314
+ + <column xsi:type="timestamp" name="date_closed" comment="Time of event"/>
315
315
<constraint xsi:type="primary" referenceId="PRIMARY">
316
316
<column name="id_column"/>
317
317
</constraint>
@@ -330,11 +330,11 @@ The following example removes the `date_closed` column by deleting its `column`
330
330
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
331
331
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
332
332
<table name="declarative_table">
333
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
334
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
333
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
334
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
335
335
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
336
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
337
- - <column xsi:type="timestamp" name="date_closed" padding="10" comment="Time of event"/>
336
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
337
+ - <column xsi:type="timestamp" name="date_closed" comment="Time of event"/>
338
338
<constraint xsi:type="primary" referenceId="PRIMARY">
339
339
<column name="id_column"/>
340
340
</constraint>
@@ -353,11 +353,11 @@ The following example changes the `type` of the `title` column from `varchar` to
353
353
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
354
354
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
355
355
<table name="declarative_table">
356
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
357
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
356
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
357
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
358
358
- <column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
359
359
+ <column xsi:type="text" name="title" nullable="false" comment="Title"/>
360
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
360
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
361
361
<constraint xsi:type="primary" referenceId="PRIMARY">
362
362
<column name="id_column"/>
363
363
</constraint>
@@ -384,10 +384,10 @@ The following example adds the `INDEX_SEVERITY` index to the `declarative_table`
384
384
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
385
385
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
386
386
<table name="declarative_table">
387
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
388
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
387
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
388
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
389
389
<column xsi:type="text" name="title" nullable="false" length="255" comment="Title"/>
390
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
390
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
391
391
<constraint xsi:type="primary" referenceId="PRIMARY">
392
392
<column name="id_column"/>
393
393
</constraint>
@@ -405,10 +405,10 @@ In the following example, the selected `constraint` node defines the characteris
405
405
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
406
406
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
407
407
<table name="declarative_table">
408
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
409
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
408
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
409
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
410
410
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
411
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
411
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
412
412
<constraint xsi:type="primary" referenceId="PRIMARY">
413
413
<column name="id_column"/>
414
414
</constraint>
@@ -430,10 +430,10 @@ The following example removes the `FL_ALLOWED_SEVERITIES` foreign key by deleti
430
430
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
431
431
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
432
432
<table name="declarative_table">
433
- <column xsi:type="int" name="id_column" padding="10" unsigned="true" nullable="false" comment="Entity Id"/>
434
- <column xsi:type="int" name="severity" padding="10" unsigned="true" nullable="false" comment="Severity code"/>
433
+ <column xsi:type="int" name="id_column" unsigned="true" nullable="false" comment="Entity Id"/>
434
+ <column xsi:type="int" name="severity" unsigned="true" nullable="false" comment="Severity code"/>
435
435
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
436
- <column xsi:type="timestamp" name="time_occurred" padding="10" comment="Time of event"/>
436
+ <column xsi:type="timestamp" name="time_occurred" comment="Time of event"/>
437
437
<constraint xsi:type="primary" referenceId="PRIMARY">
438
438
<column name="id_column"/>
439
439
</constraint>
@@ -458,7 +458,7 @@ Module B disables the original primary key and sets a new primary key with a `re
458
458
<schema xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
459
459
xsi : noNamespaceSchemaLocation =" urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd" >
460
460
<table name =" declarative_table" >
461
- <column xsi : type =" int" name =" id_column" padding = " 10 " unsigned =" true" nullable =" false" comment =" Entity Id" />
461
+ <column xsi : type =" int" name =" id_column" unsigned =" true" nullable =" false" comment =" Entity Id" />
462
462
<constraint xsi : type =" primary" referenceId =" PRIMARY" >
463
463
<column name =" id_column" />
464
464
</constraint >
@@ -472,7 +472,7 @@ Module B disables the original primary key and sets a new primary key with a `re
472
472
<schema xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
473
473
xsi : noNamespaceSchemaLocation =" urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd" >
474
474
<table name =" declarative_table" >
475
- <column xsi : type =" int" name =" new_id_column" padding = " 10 " unsigned =" true" nullable =" false"
475
+ <column xsi : type =" int" name =" new_id_column" unsigned =" true" nullable =" false"
476
476
comment =" New Entity Id" />
477
477
<constraint xsi : type =" primary" referenceId =" PRIMARY" disabled =" true" />
478
478
<constraint xsi : type =" primary" referenceId =" NEW_PRIMARY" >
0 commit comments