1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="tax_class" resource="default" engine="innodb" comment="Tax Class">
<column xsi:type="smallint" name="class_id" padding="6" unsigned="false" nullable="false" identity="true"
comment="Class Id"/>
<column xsi:type="varchar" name="class_name" nullable="false" length="255" comment="Class Name"/>
<column xsi:type="varchar" name="class_type" nullable="false" length="8" default="CUSTOMER"
comment="Class Type"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="class_id"/>
</constraint>
</table>
<table name="tax_calculation_rule" resource="default" engine="innodb" comment="Tax Calculation Rule">
<column xsi:type="int" name="tax_calculation_rule_id" padding="11" unsigned="false" nullable="false"
identity="true" comment="Tax Calculation Rule Id"/>
<column xsi:type="varchar" name="code" nullable="false" length="255" comment="Code"/>
<column xsi:type="int" name="priority" padding="11" unsigned="false" nullable="false" identity="false"
comment="Priority"/>
<column xsi:type="int" name="position" padding="11" unsigned="false" nullable="false" identity="false"
comment="Position"/>
<column xsi:type="int" name="calculate_subtotal" padding="11" unsigned="false" nullable="false" identity="false"
comment="Calculate off subtotal option"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="tax_calculation_rule_id"/>
</constraint>
<index referenceId="TAX_CALCULATION_RULE_PRIORITY_POSITION" indexType="btree">
<column name="priority"/>
<column name="position"/>
</index>
<index referenceId="TAX_CALCULATION_RULE_CODE" indexType="btree">
<column name="code"/>
</index>
</table>
<table name="tax_calculation_rate" resource="default" engine="innodb" comment="Tax Calculation Rate">
<column xsi:type="int" name="tax_calculation_rate_id" padding="11" unsigned="false" nullable="false"
identity="true" comment="Tax Calculation Rate Id"/>
<column xsi:type="varchar" name="tax_country_id" nullable="false" length="2" comment="Tax Country Id"/>
<column xsi:type="int" name="tax_region_id" padding="11" unsigned="false" nullable="false" identity="false"
comment="Tax Region Id"/>
<column xsi:type="varchar" name="tax_postcode" nullable="true" length="21" comment="Tax Postcode"/>
<column xsi:type="varchar" name="code" nullable="false" length="255" comment="Code"/>
<column xsi:type="decimal" name="rate" scale="4" precision="12" unsigned="false" nullable="false"
comment="Rate"/>
<column xsi:type="smallint" name="zip_is_range" padding="6" unsigned="false" nullable="true" identity="false"
comment="Zip Is Range"/>
<column xsi:type="int" name="zip_from" padding="10" unsigned="true" nullable="true" identity="false"
comment="Zip From"/>
<column xsi:type="int" name="zip_to" padding="10" unsigned="true" nullable="true" identity="false"
comment="Zip To"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="tax_calculation_rate_id"/>
</constraint>
<index referenceId="TAX_CALCULATION_RATE_TAX_COUNTRY_ID_TAX_REGION_ID_TAX_POSTCODE" indexType="btree">
<column name="tax_country_id"/>
<column name="tax_region_id"/>
<column name="tax_postcode"/>
</index>
<index referenceId="TAX_CALCULATION_RATE_CODE" indexType="btree">
<column name="code"/>
</index>
<index referenceId="IDX_CA799F1E2CB843495F601E56C84A626D" indexType="btree">
<column name="tax_calculation_rate_id"/>
<column name="tax_country_id"/>
<column name="tax_region_id"/>
<column name="zip_is_range"/>
<column name="tax_postcode"/>
</index>
</table>
<table name="tax_calculation" resource="default" engine="innodb" comment="Tax Calculation">
<column xsi:type="int" name="tax_calculation_id" padding="11" unsigned="false" nullable="false" identity="true"
comment="Tax Calculation Id"/>
<column xsi:type="int" name="tax_calculation_rate_id" padding="11" unsigned="false" nullable="false"
identity="false" comment="Tax Calculation Rate Id"/>
<column xsi:type="int" name="tax_calculation_rule_id" padding="11" unsigned="false" nullable="false"
identity="false" comment="Tax Calculation Rule Id"/>
<column xsi:type="smallint" name="customer_tax_class_id" padding="6" unsigned="false" nullable="false"
identity="false" comment="Customer Tax Class Id"/>
<column xsi:type="smallint" name="product_tax_class_id" padding="6" unsigned="false" nullable="false"
identity="false" comment="Product Tax Class Id"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="tax_calculation_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="TAX_CALCULATION_PRODUCT_TAX_CLASS_ID_TAX_CLASS_CLASS_ID"
table="tax_calculation" column="product_tax_class_id" referenceTable="tax_class"
referenceColumn="class_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="TAX_CALCULATION_CUSTOMER_TAX_CLASS_ID_TAX_CLASS_CLASS_ID"
table="tax_calculation" column="customer_tax_class_id" referenceTable="tax_class"
referenceColumn="class_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="TAX_CALC_TAX_CALC_RATE_ID_TAX_CALC_RATE_TAX_CALC_RATE_ID"
table="tax_calculation" column="tax_calculation_rate_id" referenceTable="tax_calculation_rate"
referenceColumn="tax_calculation_rate_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="TAX_CALC_TAX_CALC_RULE_ID_TAX_CALC_RULE_TAX_CALC_RULE_ID"
table="tax_calculation" column="tax_calculation_rule_id" referenceTable="tax_calculation_rule"
referenceColumn="tax_calculation_rule_id" onDelete="CASCADE"/>
<index referenceId="TAX_CALCULATION_TAX_CALCULATION_RULE_ID" indexType="btree">
<column name="tax_calculation_rule_id"/>
</index>
<index referenceId="TAX_CALCULATION_CUSTOMER_TAX_CLASS_ID" indexType="btree">
<column name="customer_tax_class_id"/>
</index>
<index referenceId="TAX_CALCULATION_PRODUCT_TAX_CLASS_ID" indexType="btree">
<column name="product_tax_class_id"/>
</index>
<index referenceId="TAX_CALC_TAX_CALC_RATE_ID_CSTR_TAX_CLASS_ID_PRD_TAX_CLASS_ID" indexType="btree">
<column name="tax_calculation_rate_id"/>
<column name="customer_tax_class_id"/>
<column name="product_tax_class_id"/>
</index>
</table>
<table name="tax_calculation_rate_title" resource="default" engine="innodb" comment="Tax Calculation Rate Title">
<column xsi:type="int" name="tax_calculation_rate_title_id" padding="11" unsigned="false" nullable="false"
identity="true" comment="Tax Calculation Rate Title Id"/>
<column xsi:type="int" name="tax_calculation_rate_id" padding="11" unsigned="false" nullable="false"
identity="false" comment="Tax Calculation Rate Id"/>
<column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
comment="Store Id"/>
<column xsi:type="varchar" name="value" nullable="false" length="255" comment="Value"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="tax_calculation_rate_title_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="TAX_CALCULATION_RATE_TITLE_STORE_ID_STORE_STORE_ID"
table="tax_calculation_rate_title" column="store_id" referenceTable="store"
referenceColumn="store_id" onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="FK_37FB965F786AD5897BB3AE90470C42AB" table="tax_calculation_rate_title"
column="tax_calculation_rate_id" referenceTable="tax_calculation_rate"
referenceColumn="tax_calculation_rate_id" onDelete="CASCADE"/>
<index referenceId="TAX_CALCULATION_RATE_TITLE_TAX_CALCULATION_RATE_ID_STORE_ID" indexType="btree">
<column name="tax_calculation_rate_id"/>
<column name="store_id"/>
</index>
<index referenceId="TAX_CALCULATION_RATE_TITLE_STORE_ID" indexType="btree">
<column name="store_id"/>
</index>
</table>
<table name="tax_order_aggregated_created" resource="sales" engine="innodb" comment="Tax Order Aggregation">
<column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Id"/>
<column xsi:type="date" name="period" comment="Period"/>
<column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="true" identity="false"
comment="Store Id"/>
<column xsi:type="varchar" name="code" nullable="false" length="255" comment="Code"/>
<column xsi:type="varchar" name="order_status" nullable="false" length="50" comment="Order Status"/>
<column xsi:type="float" name="percent" unsigned="false" nullable="true" comment="Percent"/>
<column xsi:type="int" name="orders_count" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Orders Count"/>
<column xsi:type="float" name="tax_base_amount_sum" unsigned="false" nullable="true"
comment="Tax Base Amount Sum"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="TAX_ORDER_AGGREGATED_CREATED_STORE_ID_STORE_STORE_ID"
table="tax_order_aggregated_created" column="store_id" referenceTable="store"
referenceColumn="store_id" onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="TAX_ORDER_AGGRED_CREATED_PERIOD_STORE_ID_CODE_PERCENT_ORDER_STS">
<column name="period"/>
<column name="store_id"/>
<column name="code"/>
<column name="percent"/>
<column name="order_status"/>
</constraint>
<index referenceId="TAX_ORDER_AGGREGATED_CREATED_STORE_ID" indexType="btree">
<column name="store_id"/>
</index>
</table>
<table name="tax_order_aggregated_updated" resource="sales" engine="innodb"
comment="Tax Order Aggregated Updated">
<column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Id"/>
<column xsi:type="date" name="period" comment="Period"/>
<column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="true" identity="false"
comment="Store Id"/>
<column xsi:type="varchar" name="code" nullable="false" length="255" comment="Code"/>
<column xsi:type="varchar" name="order_status" nullable="false" length="50" comment="Order Status"/>
<column xsi:type="float" name="percent" unsigned="false" nullable="true" comment="Percent"/>
<column xsi:type="int" name="orders_count" padding="10" unsigned="true" nullable="false" identity="false"
default="0" comment="Orders Count"/>
<column xsi:type="float" name="tax_base_amount_sum" unsigned="false" nullable="true"
comment="Tax Base Amount Sum"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="TAX_ORDER_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID"
table="tax_order_aggregated_updated" column="store_id" referenceTable="store"
referenceColumn="store_id" onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="TAX_ORDER_AGGRED_UPDATED_PERIOD_STORE_ID_CODE_PERCENT_ORDER_STS">
<column name="period"/>
<column name="store_id"/>
<column name="code"/>
<column name="percent"/>
<column name="order_status"/>
</constraint>
<index referenceId="TAX_ORDER_AGGREGATED_UPDATED_STORE_ID" indexType="btree">
<column name="store_id"/>
</index>
</table>
</schema>