Skip to content

Commit 6de59e9

Browse files
author
Sergii Kovalenko
committed
MAGETWO-81030: Schema Validation
1 parent 2db410a commit 6de59e9

File tree

18 files changed

+253
-201
lines changed

18 files changed

+253
-201
lines changed

setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationRules/AutoIncrementColumnValidation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AutoIncrementColumnValidation implements ValidationInterface
2525
/**
2626
* Error message, that will be shown.
2727
*/
28-
const ERROR_MESSAGE = 'Auto Increment column do not have index. Column - "%s"';
28+
const ERROR_MESSAGE = 'Auto Increment column do not have index. Column - "%s", table - "%s"';
2929

3030
/**
3131
* @inheritdoc
@@ -54,7 +54,7 @@ public function validate(Schema $schema)
5454

5555
$errors[] = [
5656
'column' => $column->getName(),
57-
'message' => sprintf(self::ERROR_MESSAGE, $column->getName())
57+
'message' => sprintf(self::ERROR_MESSAGE, $column->getName(), $table->getName())
5858
];
5959
}
6060
}

setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/constraints/primary.xsd" />
3535
<!--Indexes-->
3636
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/index.xsd" />
37+
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd" />
3738

3839
<xs:element name="schema">
3940
<xs:complexType>
@@ -50,7 +51,7 @@
5051
</xs:documentation>
5152
</xs:annotation>
5253
<xs:choice minOccurs="0" maxOccurs="unbounded">
53-
<xs:element name="column" />
54+
<xs:element name="column" type="abstractColumnType"/>
5455
<xs:element name="constraint" />
5556
<xs:element name="index" type="index" />
5657
</xs:choice>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd"/>
1010

1111
<xs:complexType name="blob">
12-
<xs:annotation>
13-
<xs:documentation>
14-
Can be used as binary source
15-
</xs:documentation>
16-
</xs:annotation>
12+
<xs:complexContent>
13+
<xs:extension base="abstractColumnType">
14+
<xs:annotation>
15+
<xs:documentation>
16+
Can be used as binary source
17+
</xs:documentation>
18+
</xs:annotation>
1719

18-
<xs:attributeGroup ref="baseColumn" />
19-
<xs:attribute name="nullable" type="xs:boolean" />
20+
<xs:attribute name="nullable" type="xs:boolean" />
21+
</xs:extension>
22+
</xs:complexContent>
2023
</xs:complexType>
2124
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd"/>
1010

1111
<xs:complexType name="longblob">
12-
<xs:annotation>
13-
<xs:documentation>
14-
Can be used as binary source. Different types can be used depends on data size
15-
you want to persist
16-
</xs:documentation>
17-
</xs:annotation>
12+
<xs:complexContent>
13+
<xs:extension base="abstractColumnType">
14+
<xs:annotation>
15+
<xs:documentation>
16+
Can be used as binary source. Different types can be used depends on data size
17+
you want to persist
18+
</xs:documentation>
19+
</xs:annotation>
1820

19-
<xs:attributeGroup ref="baseColumn" />
20-
<xs:attribute name="nullable" type="xs:boolean" />
21+
<xs:attribute name="nullable" type="xs:boolean" />
22+
</xs:extension>
23+
</xs:complexContent>
2124
</xs:complexType>
2225
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd"/>
1010

1111
<xs:complexType name="mediumblob">
12-
<xs:annotation>
13-
<xs:documentation>
14-
Can be used as binary source
15-
</xs:documentation>
16-
</xs:annotation>
12+
<xs:complexContent>
13+
<xs:extension base="abstractColumnType">
14+
<xs:annotation>
15+
<xs:documentation>
16+
Can be used as binary source
17+
</xs:documentation>
18+
</xs:annotation>
1719

18-
<xs:attributeGroup ref="baseColumn" />
19-
<xs:attribute name="nullable" type="xs:boolean" />
20+
<xs:attribute name="nullable" type="xs:boolean" />
21+
</xs:extension>
22+
</xs:complexContent>
2023
</xs:complexType>
2124
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/varbinary.xsd

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd"/>
1010

1111
<xs:complexType name="varbinary">
12-
<xs:annotation>
13-
<xs:documentation>
14-
Can be used as binary source
15-
</xs:documentation>
16-
</xs:annotation>
12+
<xs:complexContent>
13+
<xs:extension base="abstractColumnType">
14+
<xs:annotation>
15+
<xs:documentation>
16+
Can be used as binary source
17+
</xs:documentation>
18+
</xs:annotation>
1719

18-
<xs:attributeGroup ref="baseColumn" />
19-
<xs:attribute name="length">
20-
<xs:simpleType>
21-
<xs:restriction base="xs:integer">
22-
<xs:maxInclusive value="255"/>
23-
</xs:restriction>
24-
</xs:simpleType>
25-
</xs:attribute>
26-
<xs:attribute name="default" type="xs:string" />
27-
<xs:attribute name="nullable" type="xs:boolean" />
20+
<xs:attribute name="length">
21+
<xs:simpleType>
22+
<xs:restriction base="xs:integer">
23+
<xs:maxInclusive value="255"/>
24+
</xs:restriction>
25+
</xs:simpleType>
26+
</xs:attribute>
27+
<xs:attribute name="default" type="xs:string" />
28+
<xs:attribute name="nullable" type="xs:boolean" />
29+
</xs:extension>
30+
</xs:complexContent>
2831
</xs:complexType>
2932
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd" />
1010

1111
<xs:complexType name="boolean">
12-
<xs:attributeGroup ref="baseColumn" />
13-
<xs:attribute name="default" type="xs:boolean" />
14-
<xs:attribute name="nullable" type="xs:boolean" />
12+
<xs:complexContent>
13+
<xs:extension base="abstractColumnType">
14+
<xs:attribute name="default" type="xs:boolean" />
15+
<xs:attribute name="nullable" type="xs:boolean" />
16+
</xs:extension>
17+
</xs:complexContent>
1518
</xs:complexType>
1619
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/operations.xsd" />
10-
1110
<xs:attributeGroup name="baseColumn">
1211
<xs:attributeGroup ref="basicOperations" />
1312
<xs:attribute name="name" type="nameType" use="required" />
@@ -20,4 +19,12 @@
2019
</xs:annotation>
2120
</xs:attribute>
2221
</xs:attributeGroup>
22+
23+
<xs:complexType name="abstractColumnType">
24+
<xs:complexContent>
25+
<xs:extension base="xs:anyType">
26+
<xs:attributeGroup ref="baseColumn" />
27+
</xs:extension>
28+
</xs:complexContent>
29+
</xs:complexType>
2330
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/date.xsd

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/column.xsd" />
1010

1111
<xs:complexType name="date">
12-
<xs:annotation>
13-
<xs:documentation>
14-
This format is used to save date (year, month, day).
15-
Probably your SQL engine will save date in this format: 'YYYY-MM-DD'
16-
Dates in invalid format will be converted to '0000-00-00' string
17-
</xs:documentation>
18-
</xs:annotation>
12+
<xs:complexContent>
13+
<xs:extension base="abstractColumnType">
14+
<xs:annotation>
15+
<xs:documentation>
16+
This format is used to save date (year, month, day).
17+
Probably your SQL engine will save date in this format: 'YYYY-MM-DD'
18+
Dates in invalid format will be converted to '0000-00-00' string
19+
</xs:documentation>
20+
</xs:annotation>
1921

20-
<xs:attribute name="nullable" type="xs:boolean" />
21-
<xs:attributeGroup ref="baseColumn" />
22+
<xs:attribute name="nullable" type="xs:boolean" />
23+
</xs:extension>
24+
</xs:complexContent>
2225
</xs:complexType>
2326
</xs:schema>

setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/datetime.xsd

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
<xs:include schemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/types/datetime/default.xsd"/>
1111

1212
<xs:complexType name="datetime">
13-
<xs:annotation>
14-
<xs:documentation>
15-
This format is used to save date (year, month, day).
16-
Probably your SQL engine will save date in this format: 'YYYY-MM-DD HH:MM::SS'
17-
Date time in invalid format will be converted to '0000-00-00 00:00:00' string
18-
Supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
19-
DateTime format save date and time in your local time zone
20-
</xs:documentation>
21-
</xs:annotation>
13+
<xs:complexContent>
14+
<xs:extension base="abstractColumnType">
15+
<xs:annotation>
16+
<xs:documentation>
17+
This format is used to save date (year, month, day).
18+
Probably your SQL engine will save date in this format: 'YYYY-MM-DD HH:MM::SS'
19+
Date time in invalid format will be converted to '0000-00-00 00:00:00' string
20+
Supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
21+
DateTime format save date and time in your local time zone
22+
</xs:documentation>
23+
</xs:annotation>
2224

23-
<xs:attributeGroup ref="baseColumn" />
24-
<xs:attributeGroup ref="default" />
25+
<xs:attributeGroup ref="default" />
26+
</xs:extension>
27+
</xs:complexContent>
2528
</xs:complexType>
2629
</xs:schema>

0 commit comments

Comments
 (0)