1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\MagentoBundle\Migrations\Schema; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Schema\Schema; |
6
|
|
|
|
7
|
|
|
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension; |
8
|
|
|
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface; |
9
|
|
|
use Oro\Bundle\NoteBundle\Migration\Extension\NoteExtension; |
10
|
|
|
use Oro\Bundle\NoteBundle\Migration\Extension\NoteExtensionAwareInterface; |
11
|
|
|
use Oro\Bundle\ActivityListBundle\Migration\Extension\ActivityListExtension; |
12
|
|
|
use Oro\Bundle\ActivityListBundle\Migration\Extension\ActivityListExtensionAwareInterface; |
13
|
|
|
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope; |
14
|
|
|
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtension; |
15
|
|
|
use Oro\Bundle\EntityExtendBundle\Migration\Extension\ExtendExtensionAwareInterface; |
16
|
|
|
use Oro\Bundle\MigrationBundle\Migration\Installation; |
17
|
|
|
use Oro\Bundle\MigrationBundle\Migration\QueryBag; |
18
|
|
|
use Oro\Bundle\TrackingBundle\Migration\Extension\IdentifierEventExtension; |
19
|
|
|
use Oro\Bundle\TrackingBundle\Migration\Extension\IdentifierEventExtensionAwareInterface; |
20
|
|
|
use Oro\Bundle\TrackingBundle\Migration\Extension\VisitEventAssociationExtension; |
21
|
|
|
use Oro\Bundle\TrackingBundle\Migration\Extension\VisitEventAssociationExtensionAwareInterface; |
22
|
|
|
|
23
|
|
|
use OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_0\OroCRMMagentoBundle as IntegrationUpdate; |
24
|
|
|
use OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_37\CreateActivityAssociation; |
25
|
|
|
use OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_38\InheritanceActivityTargets; |
26
|
|
|
use OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_40\CreateActivityAssociation as OrderActivityAssociation; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @SuppressWarnings(PHPMD.TooManyMethods) |
30
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassLength) |
31
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
32
|
|
|
*/ |
33
|
|
|
class OroCRMMagentoBundleInstaller implements |
34
|
|
|
Installation, |
35
|
|
|
ActivityExtensionAwareInterface, |
36
|
|
|
IdentifierEventExtensionAwareInterface, |
37
|
|
|
ExtendExtensionAwareInterface, |
38
|
|
|
VisitEventAssociationExtensionAwareInterface, |
39
|
|
|
ActivityListExtensionAwareInterface, |
40
|
|
|
NoteExtensionAwareInterface |
41
|
|
|
{ |
42
|
|
|
/** @var ActivityExtension */ |
43
|
|
|
protected $activityExtension; |
44
|
|
|
|
45
|
|
|
/** @var NoteExtension */ |
46
|
|
|
protected $noteExtension; |
47
|
|
|
|
48
|
|
|
/** @var IdentifierEventExtension */ |
49
|
|
|
protected $identifierEventExtension; |
50
|
|
|
|
51
|
|
|
/** @var ExtendExtension $extendExtension */ |
52
|
|
|
protected $extendExtension; |
53
|
|
|
|
54
|
|
|
/** @var VisitEventAssociationExtension */ |
55
|
|
|
protected $visitExtension; |
56
|
|
|
|
57
|
|
|
/** @var ActivityListExtension */ |
58
|
|
|
protected $activityListExtension; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function setActivityListExtension(ActivityListExtension $activityListExtension) |
64
|
|
|
{ |
65
|
|
|
$this->activityListExtension = $activityListExtension; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function setActivityExtension(ActivityExtension $activityExtension) |
72
|
|
|
{ |
73
|
|
|
$this->activityExtension = $activityExtension; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
public function setNoteExtension(NoteExtension $noteExtension) |
80
|
|
|
{ |
81
|
|
|
$this->noteExtension = $noteExtension; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
|
|
public function setIdentifierEventExtension(IdentifierEventExtension $identifierEventExtension) |
88
|
|
|
{ |
89
|
|
|
$this->identifierEventExtension = $identifierEventExtension; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* {@inheritdoc} |
94
|
|
|
*/ |
95
|
|
|
public function setExtendExtension(ExtendExtension $extendExtension) |
96
|
|
|
{ |
97
|
|
|
$this->extendExtension = $extendExtension; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
|
|
public function setVisitEventAssociationExtension(VisitEventAssociationExtension $extension) |
104
|
|
|
{ |
105
|
|
|
$this->visitExtension = $extension; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* {@inheritdoc} |
110
|
|
|
*/ |
111
|
|
|
public function getMigrationVersion() |
112
|
|
|
{ |
113
|
|
|
return 'v1_41'; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* {@inheritdoc} |
118
|
|
|
*/ |
119
|
|
|
public function up(Schema $schema, QueryBag $queries) |
120
|
|
|
{ |
121
|
|
|
/** Tables generation **/ |
122
|
|
|
$this->createOrocrmMagentoRegionTable($schema); |
123
|
|
|
$this->createOrocrmMagentoCartAddressTable($schema); |
124
|
|
|
$this->createOrocrmMagentoOrderTable($schema); |
125
|
|
|
|
126
|
|
|
$this->createOrocrmMagentoOrderEmailsTable($schema); |
127
|
|
|
$this->createOrocrmMagentoCustomerGroupTable($schema); |
128
|
|
|
$this->createOrocrmMagentoCustomerTable($schema); |
129
|
|
|
$this->createOrocrmMagentoCartItemTable($schema); |
130
|
|
|
$this->createOrocrmMagentoCustomerAddrTable($schema); |
131
|
|
|
$this->createOrocrmMagentoCustAddrTypeTable($schema); |
132
|
|
|
$this->createOrocrmMagentoOrderAddressTable($schema); |
133
|
|
|
$this->createOrocrmMagentoOrderAddrTypeTable($schema); |
134
|
|
|
$this->createOrocrmMagentoProductTable($schema); |
135
|
|
|
$this->createOrocrmMagentoProdToWebsiteTable($schema); |
136
|
|
|
$this->createOrocrmMagentoWebsiteTable($schema); |
137
|
|
|
$this->createOrocrmMagentoCartTable($schema); |
138
|
|
|
|
139
|
|
|
$this->createOrocrmMagentoCartEmailsTable($schema); |
140
|
|
|
$this->createOrocrmMagentoStoreTable($schema); |
141
|
|
|
$this->createOrocrmMagentoCartStatusTable($schema); |
142
|
|
|
$this->createOrocrmMagentoOrderItemsTable($schema); |
143
|
|
|
$this->createOrocrmMagentoNewslSubscrTable($schema); |
144
|
|
|
$this->updateIntegrationTransportTable($schema); |
145
|
|
|
|
146
|
|
|
/** Foreign keys generation **/ |
147
|
|
|
$this->addOrocrmMagentoCartAddressForeignKeys($schema); |
148
|
|
|
$this->addOrocrmMagentoOrderForeignKeys($schema); |
149
|
|
|
|
150
|
|
|
$this->addOrocrmMagentoOrderEmailsForeignKeys($schema); |
151
|
|
|
$this->addOrocrmMagentoCustomerGroupForeignKeys($schema); |
152
|
|
|
$this->addOrocrmMagentoCustomerForeignKeys($schema); |
153
|
|
|
$this->addOrocrmMagentoCartItemForeignKeys($schema); |
154
|
|
|
$this->addOrocrmMagentoCustomerAddrForeignKeys($schema); |
155
|
|
|
$this->addOrocrmMagentoCustAddrTypeForeignKeys($schema); |
156
|
|
|
$this->addOrocrmMagentoOrderAddressForeignKeys($schema); |
157
|
|
|
$this->addOrocrmMagentoOrderAddrTypeForeignKeys($schema); |
158
|
|
|
$this->addOrocrmMagentoProductForeignKeys($schema); |
159
|
|
|
$this->addOrocrmMagentoProdToWebsiteForeignKeys($schema); |
160
|
|
|
$this->addOrocrmMagentoWebsiteForeignKeys($schema); |
161
|
|
|
$this->addOrocrmMagentoCartForeignKeys($schema); |
162
|
|
|
|
163
|
|
|
$this->addOrocrmMagentoCartEmailsForeignKeys($schema); |
164
|
|
|
$this->addOrocrmMagentoStoreForeignKeys($schema); |
165
|
|
|
$this->addOrocrmMagentoOrderItemsForeignKeys($schema); |
166
|
|
|
$this->addOrocrmMagentoNewslSubscrForeignKeys($schema); |
167
|
|
|
|
168
|
|
|
$this->addActivityAssociations($schema); |
169
|
|
|
OrderActivityAssociation::addNoteAssociations($schema, $this->noteExtension); |
170
|
|
|
$this->addIdentifierEventAssociations($schema); |
171
|
|
|
InheritanceActivityTargets::addInheritanceTargets($schema, $this->activityListExtension); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Update oro_integration_transport table. |
176
|
|
|
* |
177
|
|
|
* @param Schema $schema |
178
|
|
|
* @throws \Doctrine\DBAL\Schema\SchemaException |
179
|
|
|
*/ |
180
|
|
|
protected function updateIntegrationTransportTable(Schema $schema) |
181
|
|
|
{ |
182
|
|
|
IntegrationUpdate::updateOroIntegrationTransportTable($schema); |
183
|
|
|
$table = $schema->getTable('oro_integration_transport'); |
184
|
|
|
$table->addColumn('admin_url', 'string', ['notnull' => false, 'length' => 255]); |
185
|
|
|
$table->addColumn('initial_sync_start_date', 'datetime', ['notnull' => false]); |
186
|
|
|
$table->addColumn('extension_version', 'string', ['notnull' => false, 'length' => 255]); |
187
|
|
|
$table->addColumn('magento_version', 'string', ['notnull' => false, 'length' => 255]); |
188
|
|
|
$table->addColumn('guest_customer_sync', 'boolean', ['notnull' => false]); |
189
|
|
|
$table->addColumn('mage_newsl_subscr_synced_to_id', 'integer', ['notnull' => false]); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Create orocrm_magento_region table |
194
|
|
|
* |
195
|
|
|
* @param Schema $schema |
196
|
|
|
*/ |
197
|
|
|
protected function createOrocrmMagentoRegionTable(Schema $schema) |
198
|
|
|
{ |
199
|
|
|
$table = $schema->createTable('orocrm_magento_region'); |
200
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
201
|
|
|
$table->addColumn('combined_code', 'string', ['length' => 60, 'precision' => 0]); |
202
|
|
|
$table->addColumn('code', 'string', ['length' => 32, 'precision' => 0]); |
203
|
|
|
$table->addColumn('country_code', 'string', ['length' => 255, 'precision' => 0]); |
204
|
|
|
$table->addColumn('region_id', 'integer', ['precision' => 0]); |
205
|
|
|
$table->addColumn('name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
206
|
|
|
$table->setPrimaryKey(['id']); |
207
|
|
|
$table->addIndex(['region_id'], 'idx_region', []); |
208
|
|
|
$table->addUniqueIndex(['combined_code'], 'unq_code'); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Create orocrm_magento_cart_address table |
213
|
|
|
* |
214
|
|
|
* @param Schema $schema |
215
|
|
|
*/ |
216
|
|
|
protected function createOrocrmMagentoCartAddressTable(Schema $schema) |
217
|
|
|
{ |
218
|
|
|
$table = $schema->createTable('orocrm_magento_cart_address'); |
219
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
220
|
|
|
$table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
221
|
|
|
$table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
222
|
|
|
$table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
223
|
|
|
$table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
224
|
|
|
$table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
225
|
|
|
$table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
226
|
|
|
$table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
227
|
|
|
$table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
228
|
|
|
$table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
229
|
|
|
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
230
|
|
|
$table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
231
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
232
|
|
|
$table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
233
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
234
|
|
|
$table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
235
|
|
|
$table->addColumn('created', 'datetime', ['precision' => 0]); |
236
|
|
|
$table->addColumn('updated', 'datetime', ['precision' => 0]); |
237
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
238
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
239
|
|
|
$table->addIndex(['country_code'], 'IDX_6978F651F026BB7C', []); |
240
|
|
|
$table->addIndex(['region_code'], 'IDX_6978F651AEB327AF', []); |
241
|
|
|
$table->setPrimaryKey(['id']); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Create orocrm_magento_order table |
246
|
|
|
* |
247
|
|
|
* @param Schema $schema |
248
|
|
|
*/ |
249
|
|
|
protected function createOrocrmMagentoOrderTable(Schema $schema) |
250
|
|
|
{ |
251
|
|
|
$table = $schema->createTable('orocrm_magento_order'); |
252
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
253
|
|
|
$table->addColumn('customer_id', 'integer', ['notnull' => false]); |
254
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
255
|
|
|
$table->addColumn('cart_id', 'integer', ['notnull' => false]); |
256
|
|
|
$table->addColumn('workflow_item_id', 'integer', ['notnull' => false]); |
257
|
|
|
$table->addColumn('workflow_step_id', 'integer', ['notnull' => false]); |
258
|
|
|
$table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
259
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
260
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
261
|
|
|
$table->addColumn('increment_id', 'string', ['length' => 60, 'precision' => 0]); |
262
|
|
|
$table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]); |
263
|
|
|
$table->addColumn('is_guest', 'boolean', ['notnull' => false, 'precision' => 0]); |
264
|
|
|
$table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
265
|
|
|
$table->addColumn('remote_ip', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
266
|
|
|
$table->addColumn('store_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
267
|
|
|
$table->addColumn('total_paid_amount', 'float', ['notnull' => false, 'precision' => 0]); |
268
|
|
|
$table->addColumn( |
269
|
|
|
'total_invoiced_amount', |
270
|
|
|
'money', |
271
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
272
|
|
|
); |
273
|
|
|
$table->addColumn( |
274
|
|
|
'total_refunded_amount', |
275
|
|
|
'money', |
276
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
277
|
|
|
); |
278
|
|
|
$table->addColumn( |
279
|
|
|
'total_canceled_amount', |
280
|
|
|
'money', |
281
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
282
|
|
|
); |
283
|
|
|
$table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]); |
284
|
|
|
$table->addColumn('feedback', 'text', ['notnull' => false, 'precision' => 0]); |
285
|
|
|
$table->addColumn('customer_email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
286
|
|
|
$table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]); |
287
|
|
|
$table->addColumn('payment_method', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
288
|
|
|
$table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
289
|
|
|
$table->addColumn( |
290
|
|
|
'subtotal_amount', |
291
|
|
|
'money', |
292
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
293
|
|
|
); |
294
|
|
|
$table->addColumn( |
295
|
|
|
'shipping_amount', |
296
|
|
|
'money', |
297
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
298
|
|
|
); |
299
|
|
|
$table->addColumn('shipping_method', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
300
|
|
|
$table->addColumn( |
301
|
|
|
'tax_amount', |
302
|
|
|
'money', |
303
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
304
|
|
|
); |
305
|
|
|
$table->addColumn( |
306
|
|
|
'discount_amount', |
307
|
|
|
'money', |
308
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
309
|
|
|
); |
310
|
|
|
$table->addColumn( |
311
|
|
|
'discount_percent', |
312
|
|
|
'percent', |
313
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
314
|
|
|
); |
315
|
|
|
$table->addColumn( |
316
|
|
|
'total_amount', |
317
|
|
|
'money', |
318
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
319
|
|
|
); |
320
|
|
|
$table->addColumn('status', 'string', ['length' => 255, 'precision' => 0]); |
321
|
|
|
$table->addColumn('created_at', 'datetime', ['precision' => 0]); |
322
|
|
|
$table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
323
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
324
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
325
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
326
|
|
|
$table->addColumn('coupon_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
327
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
328
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
329
|
|
|
$table->addIndex(['customer_id'], 'IDX_4D09F3059395C3F3', []); |
330
|
|
|
$table->addIndex(['store_id'], 'IDX_4D09F305B092A811', []); |
331
|
|
|
$table->addIndex(['cart_id'], 'IDX_4D09F3051AD5CDBF', []); |
332
|
|
|
$table->addUniqueIndex(['workflow_item_id'], 'UNIQ_4D09F3051023C4EE'); |
333
|
|
|
$table->addIndex(['workflow_step_id'], 'IDX_4D09F30571FE882C', []); |
334
|
|
|
$table->addIndex(['user_owner_id'], 'IDX_4D09F3059EB185F9', []); |
335
|
|
|
$table->addIndex(['channel_id'], 'IDX_4D09F30572F5A1AA', []); |
336
|
|
|
$table->addIndex(['data_channel_id'], 'IDX_4D09F305BDC09B73', []); |
337
|
|
|
$table->addIndex(['organization_id'], 'IDX_4D09F30532C8A3DE', []); |
338
|
|
|
$table->setPrimaryKey(['id']); |
339
|
|
|
$table->addIndex(['created_at'], 'mageorder_created_idx', []); |
340
|
|
|
$table->addUniqueIndex(['increment_id', 'channel_id'], 'unq_increment_id_channel_id'); |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
|
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* Create orocrm_magento_order_emails table |
347
|
|
|
* |
348
|
|
|
* @param Schema $schema |
349
|
|
|
*/ |
350
|
|
View Code Duplication |
protected function createOrocrmMagentoOrderEmailsTable(Schema $schema) |
|
|
|
|
351
|
|
|
{ |
352
|
|
|
$table = $schema->createTable('orocrm_magento_order_emails'); |
353
|
|
|
$table->addColumn('order_id', 'integer', []); |
354
|
|
|
$table->addColumn('email_id', 'integer', []); |
355
|
|
|
$table->addIndex(['order_id'], 'IDX_10E2A9508D9F6D38', []); |
356
|
|
|
$table->addIndex(['email_id'], 'IDX_10E2A950A832C1C9', []); |
357
|
|
|
$table->setPrimaryKey(['order_id', 'email_id']); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Create orocrm_magento_customer_group table |
362
|
|
|
* |
363
|
|
|
* @param Schema $schema |
364
|
|
|
*/ |
365
|
|
|
protected function createOrocrmMagentoCustomerGroupTable(Schema $schema) |
366
|
|
|
{ |
367
|
|
|
$table = $schema->createTable('orocrm_magento_customer_group'); |
368
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
369
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
370
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
371
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
372
|
|
|
$table->addIndex(['channel_id'], 'IDX_71E09CA872F5A1AA', []); |
373
|
|
|
$table->setPrimaryKey(['id']); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* Create orocrm_magento_customer table |
378
|
|
|
* |
379
|
|
|
* @param Schema $schema |
380
|
|
|
*/ |
381
|
|
|
protected function createOrocrmMagentoCustomerTable(Schema $schema) |
382
|
|
|
{ |
383
|
|
|
$table = $schema->createTable('orocrm_magento_customer'); |
384
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
385
|
|
|
$table->addColumn('website_id', 'integer', ['notnull' => false]); |
386
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
387
|
|
|
$table->addColumn('customer_group_id', 'integer', ['notnull' => false]); |
388
|
|
|
$table->addColumn('contact_id', 'integer', ['notnull' => false]); |
389
|
|
|
$table->addColumn('account_id', 'integer', ['notnull' => false]); |
390
|
|
|
$table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
391
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
392
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
393
|
|
|
$table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
394
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
395
|
|
|
$table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
396
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
397
|
|
|
$table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
398
|
|
|
$table->addColumn('gender', 'string', ['notnull' => false, 'length' => 8, 'precision' => 0]); |
399
|
|
|
$table->addColumn('birthday', 'date', ['notnull' => false, 'precision' => 0]); |
400
|
|
|
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
401
|
|
|
$table->addColumn('created_at', 'datetime', ['precision' => 0]); |
402
|
|
|
$table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
403
|
|
|
$table->addColumn('is_active', 'boolean', ['precision' => 0]); |
404
|
|
|
$table->addColumn('vat', 'string', ['notnull' => false, 'length' => 255]); |
405
|
|
|
$table->addColumn('lifetime', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
406
|
|
|
$table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]); |
407
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
408
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
409
|
|
|
$table->addColumn('rfm_recency', 'integer', ['notnull' => false]); |
410
|
|
|
$table->addColumn('rfm_frequency', 'integer', ['notnull' => false]); |
411
|
|
|
$table->addColumn('rfm_monetary', 'integer', ['notnull' => false]); |
412
|
|
|
$table->addColumn('sync_state', 'integer', ['notnull' => false]); |
413
|
|
|
$table->addColumn('password', 'string', ['notnull' => false, 'length' => 32]); |
414
|
|
|
$table->addColumn('created_in', 'string', ['notnull' => false, 'length' => 255]); |
415
|
|
|
$table->addColumn('is_confirmed', 'boolean', ['notnull' => false]); |
416
|
|
|
$table->addColumn('is_guest', 'boolean', ['notnull' => true, 'default' => false]); |
417
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
418
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
419
|
|
|
$table->addIndex(['website_id'], 'IDX_2A61EE7D18F45C82', []); |
420
|
|
|
$table->addIndex(['store_id'], 'IDX_2A61EE7DB092A811', []); |
421
|
|
|
$table->addIndex(['customer_group_id'], 'IDX_2A61EE7DD2919A68', []); |
422
|
|
|
$table->addIndex(['contact_id'], 'IDX_2A61EE7DE7A1254A', []); |
423
|
|
|
$table->addIndex(['account_id'], 'IDX_2A61EE7D9B6B5FBA', []); |
424
|
|
|
$table->addIndex(['user_owner_id'], 'IDX_2A61EE7D9EB185F9', []); |
425
|
|
|
$table->addIndex(['channel_id'], 'IDX_2A61EE7D72F5A1AA', []); |
426
|
|
|
$table->addIndex(['data_channel_id'], 'IDX_2A61EE7DBDC09B73', []); |
427
|
|
|
$table->addIndex(['organization_id'], 'IDX_2A61EE7D32C8A3DE', []); |
428
|
|
|
$table->setPrimaryKey(['id']); |
429
|
|
|
$table->addIndex(['first_name', 'last_name'], 'magecustomer_name_idx', []); |
430
|
|
|
$table->addIndex(['last_name', 'first_name'], 'magecustomer_rev_name_idx', []); |
431
|
|
|
$table->addIndex(['email'], 'magecustomer_email_guest_idx', []); |
432
|
|
|
$table->addUniqueIndex(['origin_id', 'channel_id'], 'magecustomer_oid_cid_unq'); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Create orocrm_magento_cart_item table |
437
|
|
|
* |
438
|
|
|
* @param Schema $schema |
439
|
|
|
*/ |
440
|
|
|
protected function createOrocrmMagentoCartItemTable(Schema $schema) |
441
|
|
|
{ |
442
|
|
|
$table = $schema->createTable('orocrm_magento_cart_item'); |
443
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
444
|
|
|
$table->addColumn('cart_id', 'integer', ['notnull' => false]); |
445
|
|
|
$table->addColumn('product_id', 'integer', ['precision' => 0, 'unsigned' => true]); |
446
|
|
|
$table->addColumn('parent_item_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
447
|
|
|
$table->addColumn('free_shipping', 'string', ['length' => 255, 'precision' => 0]); |
448
|
|
|
$table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
449
|
|
|
$table->addColumn('tax_class_id', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
450
|
|
|
$table->addColumn('description', 'text', ['notnull' => false, 'precision' => 0]); |
451
|
|
|
$table->addColumn('is_virtual', 'boolean', ['precision' => 0]); |
452
|
|
|
$table->addColumn( |
453
|
|
|
'custom_price', |
454
|
|
|
'money', |
455
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
456
|
|
|
); |
457
|
|
|
$table->addColumn( |
458
|
|
|
'price_incl_tax', |
459
|
|
|
'money', |
460
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
461
|
|
|
); |
462
|
|
|
$table->addColumn('row_total', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
463
|
|
|
$table->addColumn('tax_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
464
|
|
|
$table->addColumn('product_type', 'string', ['length' => 255, 'precision' => 0]); |
465
|
|
|
$table->addColumn('product_image_url', 'text', ['notnull' => false]); |
466
|
|
|
$table->addColumn('product_url', 'text', ['notnull' => false]); |
467
|
|
|
$table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
468
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
469
|
|
|
$table->addColumn('qty', 'float', ['precision' => 0]); |
470
|
|
|
$table->addColumn('price', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
471
|
|
|
$table->addColumn('discount_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
472
|
|
|
$table->addColumn('tax_percent', 'percent', ['precision' => 0, 'comment' => '(DC2Type:percent)']); |
473
|
|
|
$table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]); |
474
|
|
|
$table->addColumn('createdAt', 'datetime', ['precision' => 0]); |
475
|
|
|
$table->addColumn('updatedAt', 'datetime', ['precision' => 0]); |
476
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
477
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
478
|
|
|
$table->addColumn('is_removed', 'boolean', ['notnull' => true, 'default' => false]); |
479
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
480
|
|
|
$table->addIndex(['cart_id'], 'IDX_A73DC8621AD5CDBF', []); |
481
|
|
|
$table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []); |
482
|
|
|
$table->setPrimaryKey(['id']); |
483
|
|
|
$table->addIndex(['origin_id'], 'magecartitem_origin_idx', []); |
484
|
|
|
$table->addIndex(['sku'], 'magecartitem_sku_idx', []); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Create orocrm_magento_customer_addr table |
489
|
|
|
* |
490
|
|
|
* @param Schema $schema |
491
|
|
|
*/ |
492
|
|
|
protected function createOrocrmMagentoCustomerAddrTable(Schema $schema) |
493
|
|
|
{ |
494
|
|
|
$table = $schema->createTable('orocrm_magento_customer_addr'); |
495
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
496
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
497
|
|
|
$table->addColumn('related_contact_address_id', 'integer', ['notnull' => false]); |
498
|
|
|
$table->addColumn('related_contact_phone_id', 'integer', ['notnull' => false]); |
499
|
|
|
$table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
500
|
|
|
$table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
501
|
|
|
$table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
502
|
|
|
$table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
503
|
|
|
$table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
504
|
|
|
$table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
505
|
|
|
$table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
506
|
|
|
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
507
|
|
|
$table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
508
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
509
|
|
|
$table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
510
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
511
|
|
|
$table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
512
|
|
|
$table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
513
|
|
|
$table->addColumn('is_primary', 'boolean', ['notnull' => false, 'precision' => 0]); |
514
|
|
|
$table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
515
|
|
|
$table->addColumn('created', 'datetime', ['precision' => 0]); |
516
|
|
|
$table->addColumn('updated', 'datetime', ['precision' => 0]); |
517
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
518
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
519
|
|
|
$table->addColumn('sync_state', 'integer', ['notnull' => false]); |
520
|
|
|
$table->addIndex(['owner_id'], 'IDX_1E239D647E3C61F9', []); |
521
|
|
|
$table->addUniqueIndex(['related_contact_address_id'], 'UNIQ_1E239D648137CB7B'); |
522
|
|
|
$table->addUniqueIndex(['related_contact_phone_id'], 'UNIQ_1E239D64E3694F65'); |
523
|
|
|
$table->addIndex(['country_code'], 'IDX_1E239D64F026BB7C', []); |
524
|
|
|
$table->addIndex(['region_code'], 'IDX_1E239D64AEB327AF', []); |
525
|
|
|
$table->setPrimaryKey(['id']); |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
/** |
529
|
|
|
* Create orocrm_magento_cust_addr_type table |
530
|
|
|
* |
531
|
|
|
* @param Schema $schema |
532
|
|
|
*/ |
533
|
|
View Code Duplication |
protected function createOrocrmMagentoCustAddrTypeTable(Schema $schema) |
|
|
|
|
534
|
|
|
{ |
535
|
|
|
$table = $schema->createTable('orocrm_magento_cust_addr_type'); |
536
|
|
|
$table->addColumn('customer_address_id', 'integer', []); |
537
|
|
|
$table->addColumn('type_name', 'string', ['length' => 16]); |
538
|
|
|
$table->addIndex(['customer_address_id'], 'IDX_308A31F187EABF7', []); |
539
|
|
|
$table->addIndex(['type_name'], 'IDX_308A31F1892CBB0E', []); |
540
|
|
|
$table->setPrimaryKey(['customer_address_id', 'type_name']); |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
/** |
544
|
|
|
* Create orocrm_magento_order_address table |
545
|
|
|
* |
546
|
|
|
* @param Schema $schema |
547
|
|
|
*/ |
548
|
|
|
protected function createOrocrmMagentoOrderAddressTable(Schema $schema) |
549
|
|
|
{ |
550
|
|
|
$table = $schema->createTable('orocrm_magento_order_address'); |
551
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
552
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
553
|
|
|
$table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
554
|
|
|
$table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
555
|
|
|
$table->addColumn('fax', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
556
|
|
|
$table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
557
|
|
|
$table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
558
|
|
|
$table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
559
|
|
|
$table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
560
|
|
|
$table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
561
|
|
|
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
562
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
563
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
564
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
565
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
566
|
|
|
$table->addIndex(['owner_id'], 'IDX_E31C6DEC7E3C61F9', []); |
567
|
|
|
$table->addIndex(['country_code'], 'IDX_E31C6DECF026BB7C', []); |
568
|
|
|
$table->addIndex(['region_code'], 'IDX_E31C6DECAEB327AF', []); |
569
|
|
|
$table->setPrimaryKey(['id']); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
/** |
573
|
|
|
* Create orocrm_magento_order_addr_type table |
574
|
|
|
* |
575
|
|
|
* @param Schema $schema |
576
|
|
|
*/ |
577
|
|
View Code Duplication |
protected function createOrocrmMagentoOrderAddrTypeTable(Schema $schema) |
|
|
|
|
578
|
|
|
{ |
579
|
|
|
$table = $schema->createTable('orocrm_magento_order_addr_type'); |
580
|
|
|
$table->addColumn('order_address_id', 'integer', []); |
581
|
|
|
$table->addColumn('type_name', 'string', ['length' => 16]); |
582
|
|
|
$table->addIndex(['order_address_id'], 'IDX_E927A18F466D5220', []); |
583
|
|
|
$table->addIndex(['type_name'], 'IDX_E927A18F892CBB0E', []); |
584
|
|
|
$table->setPrimaryKey(['order_address_id', 'type_name']); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* Create orocrm_magento_product table |
589
|
|
|
* |
590
|
|
|
* @param Schema $schema |
591
|
|
|
*/ |
592
|
|
|
protected function createOrocrmMagentoProductTable(Schema $schema) |
593
|
|
|
{ |
594
|
|
|
$table = $schema->createTable('orocrm_magento_product'); |
595
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
596
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
597
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
598
|
|
|
$table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
599
|
|
|
$table->addColumn('type', 'string', ['length' => 255, 'precision' => 0]); |
600
|
|
|
$table->addColumn( |
601
|
|
|
'special_price', |
602
|
|
|
'money', |
603
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
604
|
|
|
); |
605
|
|
|
$table->addColumn('price', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
606
|
|
|
$table->addColumn('created_at', 'datetime', ['precision' => 0]); |
607
|
|
|
$table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
608
|
|
|
$table->addColumn('origin_id', 'integer', ['precision' => 0, 'unsigned' => true]); |
609
|
|
|
$table->addColumn('cost', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
610
|
|
|
$table->addIndex(['channel_id'], 'IDX_5A17298272F5A1AA', []); |
611
|
|
|
$table->setPrimaryKey(['id']); |
612
|
|
|
$table->addUniqueIndex(['sku', 'channel_id'], 'unq_sku_channel_id'); |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
/** |
616
|
|
|
* Create orocrm_magento_prod_to_website table |
617
|
|
|
* |
618
|
|
|
* @param Schema $schema |
619
|
|
|
*/ |
620
|
|
View Code Duplication |
protected function createOrocrmMagentoProdToWebsiteTable(Schema $schema) |
|
|
|
|
621
|
|
|
{ |
622
|
|
|
$table = $schema->createTable('orocrm_magento_prod_to_website'); |
623
|
|
|
$table->addColumn('product_id', 'integer', []); |
624
|
|
|
$table->addColumn('website_id', 'integer', []); |
625
|
|
|
$table->addIndex(['product_id'], 'IDX_9BB836554584665A', []); |
626
|
|
|
$table->addIndex(['website_id'], 'IDX_9BB8365518F45C82', []); |
627
|
|
|
$table->setPrimaryKey(['product_id', 'website_id']); |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* Create orocrm_magento_website table |
632
|
|
|
* |
633
|
|
|
* @param Schema $schema |
634
|
|
|
*/ |
635
|
|
|
protected function createOrocrmMagentoWebsiteTable(Schema $schema) |
636
|
|
|
{ |
637
|
|
|
$table = $schema->createTable('orocrm_magento_website'); |
638
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
639
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
640
|
|
|
$table->addColumn('website_code', 'string', ['length' => 32, 'precision' => 0]); |
641
|
|
|
$table->addColumn('website_name', 'string', ['length' => 255, 'precision' => 0]); |
642
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
643
|
|
|
$table->addColumn('sort_order', 'integer', ['notnull' => false]); |
644
|
|
|
$table->addColumn('is_default', 'boolean', ['notnull' => false]); |
645
|
|
|
$table->addColumn('default_group_id', 'integer', ['notnull' => false]); |
646
|
|
|
$table->addIndex(['channel_id'], 'IDX_CE3270C872F5A1AA', []); |
647
|
|
|
$table->setPrimaryKey(['id']); |
648
|
|
|
$table->addIndex(['website_name'], 'orocrm_magento_website_name_idx', []); |
649
|
|
|
$table->addUniqueIndex(['website_code', 'origin_id', 'channel_id'], 'unq_site_idx'); |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
/** |
653
|
|
|
* Create orocrm_magento_cart table |
654
|
|
|
* |
655
|
|
|
* @param Schema $schema |
656
|
|
|
*/ |
657
|
|
|
protected function createOrocrmMagentoCartTable(Schema $schema) |
658
|
|
|
{ |
659
|
|
|
$table = $schema->createTable('orocrm_magento_cart'); |
660
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
661
|
|
|
$table->addColumn('customer_id', 'integer', ['notnull' => false]); |
662
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
663
|
|
|
$table->addColumn('shipping_address_id', 'integer', ['notnull' => false]); |
664
|
|
|
$table->addColumn('billing_address_id', 'integer', ['notnull' => false]); |
665
|
|
|
$table->addColumn('status_name', 'string', ['notnull' => false, 'length' => 32]); |
666
|
|
|
$table->addColumn('opportunity_id', 'integer', ['notnull' => false]); |
667
|
|
|
$table->addColumn('workflow_item_id', 'integer', ['notnull' => false]); |
668
|
|
|
$table->addColumn('workflow_step_id', 'integer', ['notnull' => false]); |
669
|
|
|
$table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
670
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
671
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
672
|
|
|
$table->addColumn('items_qty', 'float', ['precision' => 0]); |
673
|
|
|
$table->addColumn('items_count', 'integer', ['precision' => 0, 'unsigned' => true]); |
674
|
|
|
$table->addColumn('base_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
675
|
|
|
$table->addColumn('store_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
676
|
|
|
$table->addColumn('quote_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
677
|
|
|
$table->addColumn('store_to_base_rate', 'float', ['precision' => 0]); |
678
|
|
|
$table->addColumn('store_to_quote_rate', 'float', ['notnull' => false, 'precision' => 0]); |
679
|
|
|
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
680
|
|
|
$table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
681
|
|
|
$table->addColumn('is_guest', 'boolean', ['precision' => 0]); |
682
|
|
|
$table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
683
|
|
|
$table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]); |
684
|
|
|
$table->addColumn('status_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
685
|
|
|
$table->addColumn('sub_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
686
|
|
|
$table->addColumn( |
687
|
|
|
'grand_total', |
688
|
|
|
'money', |
689
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
690
|
|
|
); |
691
|
|
|
$table->addColumn( |
692
|
|
|
'tax_amount', |
693
|
|
|
'money', |
694
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
695
|
|
|
); |
696
|
|
|
$table->addColumn('createdAt', 'datetime', ['precision' => 0]); |
697
|
|
|
$table->addColumn('updatedAt', 'datetime', ['precision' => 0]); |
698
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
699
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
700
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
701
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
702
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
703
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
704
|
|
|
$table->addIndex(['customer_id'], 'IDX_96661A809395C3F3', []); |
705
|
|
|
$table->addIndex(['store_id'], 'IDX_96661A80B092A811', []); |
706
|
|
|
$table->addIndex(['shipping_address_id'], 'IDX_96661A804D4CFF2B', []); |
707
|
|
|
$table->addIndex(['billing_address_id'], 'IDX_96661A8079D0C0E4', []); |
708
|
|
|
$table->addIndex(['status_name'], 'IDX_96661A806625D392', []); |
709
|
|
|
$table->addIndex(['opportunity_id'], 'IDX_96661A809A34590F', []); |
710
|
|
|
$table->addUniqueIndex(['workflow_item_id'], 'UNIQ_96661A801023C4EE'); |
711
|
|
|
$table->addIndex(['workflow_step_id'], 'IDX_96661A8071FE882C', []); |
712
|
|
|
$table->addIndex(['user_owner_id'], 'IDX_96661A809EB185F9', []); |
713
|
|
|
$table->addIndex(['channel_id'], 'IDX_96661A8072F5A1AA', []); |
714
|
|
|
$table->addIndex(['data_channel_id'], 'IDX_96661A80BDC09B73', []); |
715
|
|
|
$table->addIndex(['organization_id'], 'IDX_96661A8032C8A3DE', []); |
716
|
|
|
$table->setPrimaryKey(['id']); |
717
|
|
|
$table->addIndex(['origin_id'], 'magecart_origin_idx', []); |
718
|
|
|
$table->addIndex(['updatedAt'], 'magecart_updated_idx', []); |
719
|
|
|
$table->addUniqueIndex(['origin_id', 'channel_id'], 'unq_cart_origin_id_channel_id'); |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
|
723
|
|
|
|
724
|
|
|
/** |
725
|
|
|
* Create orocrm_magento_cart_emails table |
726
|
|
|
* |
727
|
|
|
* @param Schema $schema |
728
|
|
|
*/ |
729
|
|
View Code Duplication |
protected function createOrocrmMagentoCartEmailsTable(Schema $schema) |
|
|
|
|
730
|
|
|
{ |
731
|
|
|
$table = $schema->createTable('orocrm_magento_cart_emails'); |
732
|
|
|
$table->addColumn('cart_id', 'integer', []); |
733
|
|
|
$table->addColumn('email_id', 'integer', []); |
734
|
|
|
$table->addIndex(['cart_id'], 'IDX_11B0F84B1AD5CDBF', []); |
735
|
|
|
$table->addIndex(['email_id'], 'IDX_11B0F84BA832C1C9', []); |
736
|
|
|
$table->setPrimaryKey(['cart_id', 'email_id']); |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
/** |
740
|
|
|
* Create orocrm_magento_store table |
741
|
|
|
* |
742
|
|
|
* @param Schema $schema |
743
|
|
|
*/ |
744
|
|
View Code Duplication |
protected function createOrocrmMagentoStoreTable(Schema $schema) |
|
|
|
|
745
|
|
|
{ |
746
|
|
|
$table = $schema->createTable('orocrm_magento_store'); |
747
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
748
|
|
|
$table->addColumn('website_id', 'integer', []); |
749
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
750
|
|
|
$table->addColumn('store_code', 'string', ['length' => 32, 'precision' => 0]); |
751
|
|
|
$table->addColumn('store_name', 'string', ['length' => 255, 'precision' => 0]); |
752
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
753
|
|
|
$table->addIndex(['website_id'], 'IDX_477738EA18F45C82', []); |
754
|
|
|
$table->addIndex(['channel_id'], 'IDX_477738EA72F5A1AA', []); |
755
|
|
|
$table->setPrimaryKey(['id']); |
756
|
|
|
$table->addUniqueIndex(['store_code', 'channel_id'], 'unq_code_channel_id'); |
757
|
|
|
} |
758
|
|
|
|
759
|
|
|
/** |
760
|
|
|
* Create orocrm_magento_cart_status table |
761
|
|
|
* |
762
|
|
|
* @param Schema $schema |
763
|
|
|
*/ |
764
|
|
|
protected function createOrocrmMagentoCartStatusTable(Schema $schema) |
765
|
|
|
{ |
766
|
|
|
$table = $schema->createTable('orocrm_magento_cart_status'); |
767
|
|
|
$table->addColumn('name', 'string', ['length' => 32, 'precision' => 0]); |
768
|
|
|
$table->addColumn('label', 'string', ['length' => 255, 'precision' => 0]); |
769
|
|
|
$table->addUniqueIndex(['label'], 'UNIQ_26317505EA750E8'); |
770
|
|
|
$table->setPrimaryKey(['name']); |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
/** |
774
|
|
|
* Create orocrm_magento_order_items table |
775
|
|
|
* |
776
|
|
|
* @param Schema $schema |
777
|
|
|
*/ |
778
|
|
|
protected function createOrocrmMagentoOrderItemsTable(Schema $schema) |
779
|
|
|
{ |
780
|
|
|
$table = $schema->createTable('orocrm_magento_order_items'); |
781
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
782
|
|
|
$table->addColumn('order_id', 'integer', ['notnull' => false]); |
783
|
|
|
$table->addColumn('product_type', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
784
|
|
|
$table->addColumn('product_options', 'text', ['notnull' => false, 'precision' => 0]); |
785
|
|
|
$table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]); |
786
|
|
|
$table->addColumn( |
787
|
|
|
'original_price', |
788
|
|
|
'money', |
789
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
790
|
|
|
); |
791
|
|
|
$table->addColumn( |
792
|
|
|
'discount_percent', |
793
|
|
|
'percent', |
794
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
795
|
|
|
); |
796
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
797
|
|
|
$table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
798
|
|
|
$table->addColumn('qty', 'float', ['precision' => 0]); |
799
|
|
|
$table->addColumn('price', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
800
|
|
|
$table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]); |
801
|
|
|
$table->addColumn( |
802
|
|
|
'tax_percent', |
803
|
|
|
'percent', |
804
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
805
|
|
|
); |
806
|
|
|
$table->addColumn( |
807
|
|
|
'tax_amount', |
808
|
|
|
'money', |
809
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
810
|
|
|
); |
811
|
|
|
$table->addColumn( |
812
|
|
|
'discount_amount', |
813
|
|
|
'money', |
814
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
815
|
|
|
); |
816
|
|
|
$table->addColumn('row_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
817
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
818
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
819
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
820
|
|
|
$table->addIndex(['order_id'], 'IDX_3135EFF68D9F6D38', []); |
821
|
|
|
$table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []); |
822
|
|
|
$table->setPrimaryKey(['id']); |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* Create orocrm_magento_newsl_subscr table |
827
|
|
|
* |
828
|
|
|
* @param Schema $schema |
829
|
|
|
*/ |
830
|
|
|
protected function createOrocrmMagentoNewslSubscrTable(Schema $schema) |
831
|
|
|
{ |
832
|
|
|
$table = $schema->createTable('orocrm_magento_newsl_subscr'); |
833
|
|
|
$table->addColumn('id', 'integer', ['autoincrement' => true]); |
834
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
835
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
836
|
|
|
$table->addColumn('customer_id', 'integer', ['notnull' => false]); |
837
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
838
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
839
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
840
|
|
|
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]); |
841
|
|
|
$table->addColumn('change_status_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
842
|
|
|
$table->addColumn('created_at', 'datetime', ['comment' => '(DC2Type:datetime)']); |
843
|
|
|
$table->addColumn('updated_at', 'datetime', ['comment' => '(DC2Type:datetime)']); |
844
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
845
|
|
|
$table->addColumn('confirm_code', 'string', ['notnull' => false, 'length' => 32]); |
846
|
|
|
$table->setPrimaryKey(['id']); |
847
|
|
|
|
848
|
|
|
$this->extendExtension->addEnumField( |
849
|
|
|
$schema, |
850
|
|
|
$table, |
851
|
|
|
'status', |
852
|
|
|
'mage_subscr_status', |
853
|
|
|
false, |
854
|
|
|
false, |
855
|
|
|
[ |
856
|
|
|
'extend' => ['owner' => ExtendScope::OWNER_CUSTOM] |
857
|
|
|
] |
858
|
|
|
); |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
/** |
862
|
|
|
* Add orocrm_magento_cart_address foreign keys. |
863
|
|
|
* |
864
|
|
|
* @param Schema $schema |
865
|
|
|
*/ |
866
|
|
|
protected function addOrocrmMagentoCartAddressForeignKeys(Schema $schema) |
867
|
|
|
{ |
868
|
|
|
$table = $schema->getTable('orocrm_magento_cart_address'); |
869
|
|
|
$table->addForeignKeyConstraint( |
870
|
|
|
$schema->getTable('oro_dictionary_country'), |
871
|
|
|
['country_code'], |
872
|
|
|
['iso2_code'], |
873
|
|
|
[] |
874
|
|
|
); |
875
|
|
|
$table->addForeignKeyConstraint( |
876
|
|
|
$schema->getTable('oro_dictionary_region'), |
877
|
|
|
['region_code'], |
878
|
|
|
['combined_code'], |
879
|
|
|
[] |
880
|
|
|
); |
881
|
|
|
$table->addForeignKeyConstraint( |
882
|
|
|
$schema->getTable('oro_integration_channel'), |
883
|
|
|
['channel_id'], |
884
|
|
|
['id'], |
885
|
|
|
['onDelete' => 'SET NULL'] |
886
|
|
|
); |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
/** |
890
|
|
|
* Add orocrm_magento_order foreign keys. |
891
|
|
|
* |
892
|
|
|
* @param Schema $schema |
893
|
|
|
*/ |
894
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderForeignKeys(Schema $schema) |
|
|
|
|
895
|
|
|
{ |
896
|
|
|
$table = $schema->getTable('orocrm_magento_order'); |
897
|
|
|
$table->addForeignKeyConstraint( |
898
|
|
|
$schema->getTable('orocrm_magento_customer'), |
899
|
|
|
['customer_id'], |
900
|
|
|
['id'], |
901
|
|
|
['onDelete' => 'SET NULL'] |
902
|
|
|
); |
903
|
|
|
$table->addForeignKeyConstraint( |
904
|
|
|
$schema->getTable('orocrm_magento_store'), |
905
|
|
|
['store_id'], |
906
|
|
|
['id'], |
907
|
|
|
['onDelete' => 'SET NULL'] |
908
|
|
|
); |
909
|
|
|
$table->addForeignKeyConstraint( |
910
|
|
|
$schema->getTable('orocrm_magento_cart'), |
911
|
|
|
['cart_id'], |
912
|
|
|
['id'], |
913
|
|
|
[] |
914
|
|
|
); |
915
|
|
|
$table->addForeignKeyConstraint( |
916
|
|
|
$schema->getTable('oro_workflow_item'), |
917
|
|
|
['workflow_item_id'], |
918
|
|
|
['id'], |
919
|
|
|
['onDelete' => 'SET NULL'] |
920
|
|
|
); |
921
|
|
|
$table->addForeignKeyConstraint( |
922
|
|
|
$schema->getTable('oro_workflow_step'), |
923
|
|
|
['workflow_step_id'], |
924
|
|
|
['id'], |
925
|
|
|
['onDelete' => 'SET NULL'] |
926
|
|
|
); |
927
|
|
|
$table->addForeignKeyConstraint( |
928
|
|
|
$schema->getTable('oro_user'), |
929
|
|
|
['user_owner_id'], |
930
|
|
|
['id'], |
931
|
|
|
['onDelete' => 'SET NULL'] |
932
|
|
|
); |
933
|
|
|
$table->addForeignKeyConstraint( |
934
|
|
|
$schema->getTable('oro_integration_channel'), |
935
|
|
|
['channel_id'], |
936
|
|
|
['id'], |
937
|
|
|
['onDelete' => 'SET NULL'] |
938
|
|
|
); |
939
|
|
|
$table->addForeignKeyConstraint( |
940
|
|
|
$schema->getTable('orocrm_channel'), |
941
|
|
|
['data_channel_id'], |
942
|
|
|
['id'], |
943
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
944
|
|
|
'FK_4D09F305BDC09B73' |
945
|
|
|
); |
946
|
|
|
$table->addForeignKeyConstraint( |
947
|
|
|
$schema->getTable('oro_organization'), |
948
|
|
|
['organization_id'], |
949
|
|
|
['id'], |
950
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
951
|
|
|
'FK_4D09F30532C8A3DE' |
952
|
|
|
); |
953
|
|
|
} |
954
|
|
|
|
955
|
|
|
|
956
|
|
|
|
957
|
|
|
/** |
958
|
|
|
* Add orocrm_magento_order_emails foreign keys. |
959
|
|
|
* |
960
|
|
|
* @param Schema $schema |
961
|
|
|
*/ |
962
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderEmailsForeignKeys(Schema $schema) |
|
|
|
|
963
|
|
|
{ |
964
|
|
|
$table = $schema->getTable('orocrm_magento_order_emails'); |
965
|
|
|
$table->addForeignKeyConstraint( |
966
|
|
|
$schema->getTable('orocrm_magento_order'), |
967
|
|
|
['order_id'], |
968
|
|
|
['id'], |
969
|
|
|
['onDelete' => 'CASCADE'] |
970
|
|
|
); |
971
|
|
|
$table->addForeignKeyConstraint( |
972
|
|
|
$schema->getTable('oro_email'), |
973
|
|
|
['email_id'], |
974
|
|
|
['id'], |
975
|
|
|
['onDelete' => 'CASCADE'] |
976
|
|
|
); |
977
|
|
|
} |
978
|
|
|
|
979
|
|
|
/** |
980
|
|
|
* Add orocrm_magento_customer_group foreign keys. |
981
|
|
|
* |
982
|
|
|
* @param Schema $schema |
983
|
|
|
*/ |
984
|
|
View Code Duplication |
protected function addOrocrmMagentoCustomerGroupForeignKeys(Schema $schema) |
|
|
|
|
985
|
|
|
{ |
986
|
|
|
$table = $schema->getTable('orocrm_magento_customer_group'); |
987
|
|
|
$table->addForeignKeyConstraint( |
988
|
|
|
$schema->getTable('oro_integration_channel'), |
989
|
|
|
['channel_id'], |
990
|
|
|
['id'], |
991
|
|
|
['onDelete' => 'SET NULL'] |
992
|
|
|
); |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
/** |
996
|
|
|
* Add orocrm_magento_customer foreign keys. |
997
|
|
|
* |
998
|
|
|
* @param Schema $schema |
999
|
|
|
*/ |
1000
|
|
View Code Duplication |
protected function addOrocrmMagentoCustomerForeignKeys(Schema $schema) |
|
|
|
|
1001
|
|
|
{ |
1002
|
|
|
$table = $schema->getTable('orocrm_magento_customer'); |
1003
|
|
|
$table->addForeignKeyConstraint( |
1004
|
|
|
$schema->getTable('orocrm_magento_website'), |
1005
|
|
|
['website_id'], |
1006
|
|
|
['id'], |
1007
|
|
|
['onDelete' => 'SET NULL'] |
1008
|
|
|
); |
1009
|
|
|
$table->addForeignKeyConstraint( |
1010
|
|
|
$schema->getTable('orocrm_magento_store'), |
1011
|
|
|
['store_id'], |
1012
|
|
|
['id'], |
1013
|
|
|
['onDelete' => 'SET NULL'] |
1014
|
|
|
); |
1015
|
|
|
$table->addForeignKeyConstraint( |
1016
|
|
|
$schema->getTable('orocrm_magento_customer_group'), |
1017
|
|
|
['customer_group_id'], |
1018
|
|
|
['id'], |
1019
|
|
|
['onDelete' => 'SET NULL'] |
1020
|
|
|
); |
1021
|
|
|
$table->addForeignKeyConstraint( |
1022
|
|
|
$schema->getTable('orocrm_contact'), |
1023
|
|
|
['contact_id'], |
1024
|
|
|
['id'], |
1025
|
|
|
['onDelete' => 'SET NULL'] |
1026
|
|
|
); |
1027
|
|
|
$table->addForeignKeyConstraint( |
1028
|
|
|
$schema->getTable('orocrm_account'), |
1029
|
|
|
['account_id'], |
1030
|
|
|
['id'], |
1031
|
|
|
['onDelete' => 'SET NULL'] |
1032
|
|
|
); |
1033
|
|
|
$table->addForeignKeyConstraint( |
1034
|
|
|
$schema->getTable('oro_user'), |
1035
|
|
|
['user_owner_id'], |
1036
|
|
|
['id'], |
1037
|
|
|
['onDelete' => 'SET NULL'] |
1038
|
|
|
); |
1039
|
|
|
$table->addForeignKeyConstraint( |
1040
|
|
|
$schema->getTable('oro_integration_channel'), |
1041
|
|
|
['channel_id'], |
1042
|
|
|
['id'], |
1043
|
|
|
['onDelete' => 'SET NULL'] |
1044
|
|
|
); |
1045
|
|
|
$table->addForeignKeyConstraint( |
1046
|
|
|
$schema->getTable('orocrm_channel'), |
1047
|
|
|
['data_channel_id'], |
1048
|
|
|
['id'], |
1049
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1050
|
|
|
'FK_2A61EE7DBDC09B73' |
1051
|
|
|
); |
1052
|
|
|
$table->addForeignKeyConstraint( |
1053
|
|
|
$schema->getTable('oro_organization'), |
1054
|
|
|
['organization_id'], |
1055
|
|
|
['id'], |
1056
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1057
|
|
|
'FK_2A61EE7D32C8A3DE' |
1058
|
|
|
); |
1059
|
|
|
} |
1060
|
|
|
|
1061
|
|
|
/** |
1062
|
|
|
* Add orocrm_magento_cart_item foreign keys. |
1063
|
|
|
* |
1064
|
|
|
* @param Schema $schema |
1065
|
|
|
*/ |
1066
|
|
View Code Duplication |
protected function addOrocrmMagentoCartItemForeignKeys(Schema $schema) |
|
|
|
|
1067
|
|
|
{ |
1068
|
|
|
$table = $schema->getTable('orocrm_magento_cart_item'); |
1069
|
|
|
$table->addForeignKeyConstraint( |
1070
|
|
|
$schema->getTable('orocrm_magento_cart'), |
1071
|
|
|
['cart_id'], |
1072
|
|
|
['id'], |
1073
|
|
|
['onDelete' => 'CASCADE'] |
1074
|
|
|
); |
1075
|
|
|
$table->addForeignKeyConstraint( |
1076
|
|
|
$schema->getTable('oro_integration_channel'), |
1077
|
|
|
['channel_id'], |
1078
|
|
|
['id'], |
1079
|
|
|
['onDelete' => 'SET NULL'] |
1080
|
|
|
); |
1081
|
|
|
$table->addForeignKeyConstraint( |
1082
|
|
|
$schema->getTable('oro_organization'), |
1083
|
|
|
['owner_id'], |
1084
|
|
|
['id'], |
1085
|
|
|
['onDelete' => 'SET NULL'] |
1086
|
|
|
); |
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
/** |
1090
|
|
|
* Add orocrm_magento_customer_addr foreign keys. |
1091
|
|
|
* |
1092
|
|
|
* @param Schema $schema |
1093
|
|
|
*/ |
1094
|
|
|
protected function addOrocrmMagentoCustomerAddrForeignKeys(Schema $schema) |
1095
|
|
|
{ |
1096
|
|
|
$table = $schema->getTable('orocrm_magento_customer_addr'); |
1097
|
|
|
$table->addForeignKeyConstraint( |
1098
|
|
|
$schema->getTable('orocrm_magento_customer'), |
1099
|
|
|
['owner_id'], |
1100
|
|
|
['id'], |
1101
|
|
|
['onDelete' => 'CASCADE'] |
1102
|
|
|
); |
1103
|
|
|
$table->addForeignKeyConstraint( |
1104
|
|
|
$schema->getTable('orocrm_contact_address'), |
1105
|
|
|
['related_contact_address_id'], |
1106
|
|
|
['id'], |
1107
|
|
|
['onDelete' => 'SET NULL'] |
1108
|
|
|
); |
1109
|
|
|
$table->addForeignKeyConstraint( |
1110
|
|
|
$schema->getTable('orocrm_contact_phone'), |
1111
|
|
|
['related_contact_phone_id'], |
1112
|
|
|
['id'], |
1113
|
|
|
['onDelete' => 'SET NULL'] |
1114
|
|
|
); |
1115
|
|
|
$table->addForeignKeyConstraint( |
1116
|
|
|
$schema->getTable('oro_dictionary_country'), |
1117
|
|
|
['country_code'], |
1118
|
|
|
['iso2_code'], |
1119
|
|
|
[] |
1120
|
|
|
); |
1121
|
|
|
$table->addForeignKeyConstraint( |
1122
|
|
|
$schema->getTable('oro_dictionary_region'), |
1123
|
|
|
['region_code'], |
1124
|
|
|
['combined_code'], |
1125
|
|
|
[] |
1126
|
|
|
); |
1127
|
|
|
$table->addForeignKeyConstraint( |
1128
|
|
|
$schema->getTable('oro_integration_channel'), |
1129
|
|
|
['channel_id'], |
1130
|
|
|
['id'], |
1131
|
|
|
['onDelete' => 'SET NULL'] |
1132
|
|
|
); |
1133
|
|
|
} |
1134
|
|
|
|
1135
|
|
|
/** |
1136
|
|
|
* Add orocrm_magento_cust_addr_type foreign keys. |
1137
|
|
|
* |
1138
|
|
|
* @param Schema $schema |
1139
|
|
|
*/ |
1140
|
|
View Code Duplication |
protected function addOrocrmMagentoCustAddrTypeForeignKeys(Schema $schema) |
|
|
|
|
1141
|
|
|
{ |
1142
|
|
|
$table = $schema->getTable('orocrm_magento_cust_addr_type'); |
1143
|
|
|
$table->addForeignKeyConstraint( |
1144
|
|
|
$schema->getTable('orocrm_magento_customer_addr'), |
1145
|
|
|
['customer_address_id'], |
1146
|
|
|
['id'], |
1147
|
|
|
['onDelete' => 'CASCADE'], |
1148
|
|
|
'FK_308A31F187EABF7' |
1149
|
|
|
); |
1150
|
|
|
$table->addForeignKeyConstraint( |
1151
|
|
|
$schema->getTable('oro_address_type'), |
1152
|
|
|
['type_name'], |
1153
|
|
|
['name'], |
1154
|
|
|
[] |
1155
|
|
|
); |
1156
|
|
|
} |
1157
|
|
|
|
1158
|
|
|
/** |
1159
|
|
|
* Add orocrm_magento_order_address foreign keys. |
1160
|
|
|
* |
1161
|
|
|
* @param Schema $schema |
1162
|
|
|
*/ |
1163
|
|
|
protected function addOrocrmMagentoOrderAddressForeignKeys(Schema $schema) |
1164
|
|
|
{ |
1165
|
|
|
$table = $schema->getTable('orocrm_magento_order_address'); |
1166
|
|
|
$table->addForeignKeyConstraint( |
1167
|
|
|
$schema->getTable('orocrm_magento_order'), |
1168
|
|
|
['owner_id'], |
1169
|
|
|
['id'], |
1170
|
|
|
['onDelete' => 'CASCADE'] |
1171
|
|
|
); |
1172
|
|
|
$table->addForeignKeyConstraint( |
1173
|
|
|
$schema->getTable('oro_dictionary_country'), |
1174
|
|
|
['country_code'], |
1175
|
|
|
['iso2_code'], |
1176
|
|
|
[] |
1177
|
|
|
); |
1178
|
|
|
$table->addForeignKeyConstraint( |
1179
|
|
|
$schema->getTable('oro_dictionary_region'), |
1180
|
|
|
['region_code'], |
1181
|
|
|
['combined_code'], |
1182
|
|
|
[] |
1183
|
|
|
); |
1184
|
|
|
$table->addForeignKeyConstraint( |
1185
|
|
|
$schema->getTable('oro_integration_channel'), |
1186
|
|
|
['channel_id'], |
1187
|
|
|
['id'], |
1188
|
|
|
['onDelete' => 'SET NULL'] |
1189
|
|
|
); |
1190
|
|
|
} |
1191
|
|
|
|
1192
|
|
|
/** |
1193
|
|
|
* Add orocrm_magento_order_addr_type foreign keys. |
1194
|
|
|
* |
1195
|
|
|
* @param Schema $schema |
1196
|
|
|
*/ |
1197
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderAddrTypeForeignKeys(Schema $schema) |
|
|
|
|
1198
|
|
|
{ |
1199
|
|
|
$table = $schema->getTable('orocrm_magento_order_addr_type'); |
1200
|
|
|
$table->addForeignKeyConstraint( |
1201
|
|
|
$schema->getTable('orocrm_magento_order_address'), |
1202
|
|
|
['order_address_id'], |
1203
|
|
|
['id'], |
1204
|
|
|
['onDelete' => 'CASCADE'], |
1205
|
|
|
'FK_E927A18F466D5220' |
1206
|
|
|
); |
1207
|
|
|
$table->addForeignKeyConstraint( |
1208
|
|
|
$schema->getTable('oro_address_type'), |
1209
|
|
|
['type_name'], |
1210
|
|
|
['name'], |
1211
|
|
|
[] |
1212
|
|
|
); |
1213
|
|
|
} |
1214
|
|
|
|
1215
|
|
|
/** |
1216
|
|
|
* Add orocrm_magento_product foreign keys. |
1217
|
|
|
* |
1218
|
|
|
* @param Schema $schema |
1219
|
|
|
*/ |
1220
|
|
View Code Duplication |
protected function addOrocrmMagentoProductForeignKeys(Schema $schema) |
|
|
|
|
1221
|
|
|
{ |
1222
|
|
|
$table = $schema->getTable('orocrm_magento_product'); |
1223
|
|
|
$table->addForeignKeyConstraint( |
1224
|
|
|
$schema->getTable('oro_integration_channel'), |
1225
|
|
|
['channel_id'], |
1226
|
|
|
['id'], |
1227
|
|
|
['onDelete' => 'SET NULL'] |
1228
|
|
|
); |
1229
|
|
|
} |
1230
|
|
|
|
1231
|
|
|
/** |
1232
|
|
|
* Add orocrm_magento_prod_to_website foreign keys. |
1233
|
|
|
* |
1234
|
|
|
* @param Schema $schema |
1235
|
|
|
*/ |
1236
|
|
View Code Duplication |
protected function addOrocrmMagentoProdToWebsiteForeignKeys(Schema $schema) |
|
|
|
|
1237
|
|
|
{ |
1238
|
|
|
$table = $schema->getTable('orocrm_magento_prod_to_website'); |
1239
|
|
|
$table->addForeignKeyConstraint( |
1240
|
|
|
$schema->getTable('orocrm_magento_product'), |
1241
|
|
|
['product_id'], |
1242
|
|
|
['id'], |
1243
|
|
|
['onDelete' => 'CASCADE'] |
1244
|
|
|
); |
1245
|
|
|
$table->addForeignKeyConstraint( |
1246
|
|
|
$schema->getTable('orocrm_magento_website'), |
1247
|
|
|
['website_id'], |
1248
|
|
|
['id'], |
1249
|
|
|
['onDelete' => 'CASCADE'] |
1250
|
|
|
); |
1251
|
|
|
} |
1252
|
|
|
|
1253
|
|
|
/** |
1254
|
|
|
* Add orocrm_magento_website foreign keys. |
1255
|
|
|
* |
1256
|
|
|
* @param Schema $schema |
1257
|
|
|
*/ |
1258
|
|
View Code Duplication |
protected function addOrocrmMagentoWebsiteForeignKeys(Schema $schema) |
|
|
|
|
1259
|
|
|
{ |
1260
|
|
|
$table = $schema->getTable('orocrm_magento_website'); |
1261
|
|
|
$table->addForeignKeyConstraint( |
1262
|
|
|
$schema->getTable('oro_integration_channel'), |
1263
|
|
|
['channel_id'], |
1264
|
|
|
['id'], |
1265
|
|
|
['onDelete' => 'SET NULL'] |
1266
|
|
|
); |
1267
|
|
|
} |
1268
|
|
|
|
1269
|
|
|
/** |
1270
|
|
|
* Add orocrm_magento_cart foreign keys. |
1271
|
|
|
* |
1272
|
|
|
* @param Schema $schema |
1273
|
|
|
*/ |
1274
|
|
|
protected function addOrocrmMagentoCartForeignKeys(Schema $schema) |
1275
|
|
|
{ |
1276
|
|
|
$table = $schema->getTable('orocrm_magento_cart'); |
1277
|
|
|
$table->addForeignKeyConstraint( |
1278
|
|
|
$schema->getTable('orocrm_magento_customer'), |
1279
|
|
|
['customer_id'], |
1280
|
|
|
['id'], |
1281
|
|
|
['onDelete' => 'CASCADE'] |
1282
|
|
|
); |
1283
|
|
|
$table->addForeignKeyConstraint( |
1284
|
|
|
$schema->getTable('orocrm_magento_store'), |
1285
|
|
|
['store_id'], |
1286
|
|
|
['id'], |
1287
|
|
|
['onDelete' => 'SET NULL'] |
1288
|
|
|
); |
1289
|
|
|
$table->addForeignKeyConstraint( |
1290
|
|
|
$schema->getTable('orocrm_magento_cart_address'), |
1291
|
|
|
['shipping_address_id'], |
1292
|
|
|
['id'], |
1293
|
|
|
['onDelete' => 'SET NULL'] |
1294
|
|
|
); |
1295
|
|
|
$table->addForeignKeyConstraint( |
1296
|
|
|
$schema->getTable('orocrm_magento_cart_address'), |
1297
|
|
|
['billing_address_id'], |
1298
|
|
|
['id'], |
1299
|
|
|
['onDelete' => 'SET NULL'] |
1300
|
|
|
); |
1301
|
|
|
$table->addForeignKeyConstraint( |
1302
|
|
|
$schema->getTable('orocrm_magento_cart_status'), |
1303
|
|
|
['status_name'], |
1304
|
|
|
['name'], |
1305
|
|
|
['onDelete' => 'SET NULL'] |
1306
|
|
|
); |
1307
|
|
|
$table->addForeignKeyConstraint( |
1308
|
|
|
$schema->getTable('orocrm_sales_opportunity'), |
1309
|
|
|
['opportunity_id'], |
1310
|
|
|
['id'], |
1311
|
|
|
['onDelete' => 'SET NULL'] |
1312
|
|
|
); |
1313
|
|
|
$table->addForeignKeyConstraint( |
1314
|
|
|
$schema->getTable('oro_workflow_item'), |
1315
|
|
|
['workflow_item_id'], |
1316
|
|
|
['id'], |
1317
|
|
|
['onDelete' => 'SET NULL'] |
1318
|
|
|
); |
1319
|
|
|
$table->addForeignKeyConstraint( |
1320
|
|
|
$schema->getTable('oro_workflow_step'), |
1321
|
|
|
['workflow_step_id'], |
1322
|
|
|
['id'], |
1323
|
|
|
['onDelete' => 'SET NULL'] |
1324
|
|
|
); |
1325
|
|
|
$table->addForeignKeyConstraint( |
1326
|
|
|
$schema->getTable('oro_user'), |
1327
|
|
|
['user_owner_id'], |
1328
|
|
|
['id'], |
1329
|
|
|
['onDelete' => 'SET NULL'] |
1330
|
|
|
); |
1331
|
|
|
$table->addForeignKeyConstraint( |
1332
|
|
|
$schema->getTable('oro_integration_channel'), |
1333
|
|
|
['channel_id'], |
1334
|
|
|
['id'], |
1335
|
|
|
['onDelete' => 'SET NULL'] |
1336
|
|
|
); |
1337
|
|
|
$table->addForeignKeyConstraint( |
1338
|
|
|
$schema->getTable('orocrm_channel'), |
1339
|
|
|
['data_channel_id'], |
1340
|
|
|
['id'], |
1341
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1342
|
|
|
'FK_96661A80BDC09B73' |
1343
|
|
|
); |
1344
|
|
|
$table->addForeignKeyConstraint( |
1345
|
|
|
$schema->getTable('oro_organization'), |
1346
|
|
|
['organization_id'], |
1347
|
|
|
['id'], |
1348
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1349
|
|
|
'FK_96661A8032C8A3DE' |
1350
|
|
|
); |
1351
|
|
|
} |
1352
|
|
|
|
1353
|
|
|
|
1354
|
|
|
|
1355
|
|
|
/** |
1356
|
|
|
* Add orocrm_magento_cart_emails foreign keys. |
1357
|
|
|
* |
1358
|
|
|
* @param Schema $schema |
1359
|
|
|
*/ |
1360
|
|
View Code Duplication |
protected function addOrocrmMagentoCartEmailsForeignKeys(Schema $schema) |
|
|
|
|
1361
|
|
|
{ |
1362
|
|
|
$table = $schema->getTable('orocrm_magento_cart_emails'); |
1363
|
|
|
$table->addForeignKeyConstraint( |
1364
|
|
|
$schema->getTable('orocrm_magento_cart'), |
1365
|
|
|
['cart_id'], |
1366
|
|
|
['id'], |
1367
|
|
|
['onDelete' => 'CASCADE'] |
1368
|
|
|
); |
1369
|
|
|
$table->addForeignKeyConstraint( |
1370
|
|
|
$schema->getTable('oro_email'), |
1371
|
|
|
['email_id'], |
1372
|
|
|
['id'], |
1373
|
|
|
['onDelete' => 'CASCADE'] |
1374
|
|
|
); |
1375
|
|
|
} |
1376
|
|
|
|
1377
|
|
|
/** |
1378
|
|
|
* Add orocrm_magento_store foreign keys. |
1379
|
|
|
* |
1380
|
|
|
* @param Schema $schema |
1381
|
|
|
*/ |
1382
|
|
View Code Duplication |
protected function addOrocrmMagentoStoreForeignKeys(Schema $schema) |
|
|
|
|
1383
|
|
|
{ |
1384
|
|
|
$table = $schema->getTable('orocrm_magento_store'); |
1385
|
|
|
$table->addForeignKeyConstraint( |
1386
|
|
|
$schema->getTable('orocrm_magento_website'), |
1387
|
|
|
['website_id'], |
1388
|
|
|
['id'], |
1389
|
|
|
['onDelete' => 'cascade'] |
1390
|
|
|
); |
1391
|
|
|
$table->addForeignKeyConstraint( |
1392
|
|
|
$schema->getTable('oro_integration_channel'), |
1393
|
|
|
['channel_id'], |
1394
|
|
|
['id'], |
1395
|
|
|
['onDelete' => 'SET NULL'] |
1396
|
|
|
); |
1397
|
|
|
} |
1398
|
|
|
|
1399
|
|
|
/** |
1400
|
|
|
* Add orocrm_magento_order_items foreign keys. |
1401
|
|
|
* |
1402
|
|
|
* @param Schema $schema |
1403
|
|
|
*/ |
1404
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderItemsForeignKeys(Schema $schema) |
|
|
|
|
1405
|
|
|
{ |
1406
|
|
|
$table = $schema->getTable('orocrm_magento_order_items'); |
1407
|
|
|
$table->addForeignKeyConstraint( |
1408
|
|
|
$schema->getTable('orocrm_magento_order'), |
1409
|
|
|
['order_id'], |
1410
|
|
|
['id'], |
1411
|
|
|
['onDelete' => 'CASCADE'] |
1412
|
|
|
); |
1413
|
|
|
$table->addForeignKeyConstraint( |
1414
|
|
|
$schema->getTable('oro_integration_channel'), |
1415
|
|
|
['channel_id'], |
1416
|
|
|
['id'], |
1417
|
|
|
['onDelete' => 'SET NULL'] |
1418
|
|
|
); |
1419
|
|
|
$table->addForeignKeyConstraint( |
1420
|
|
|
$schema->getTable('oro_organization'), |
1421
|
|
|
['owner_id'], |
1422
|
|
|
['id'], |
1423
|
|
|
['onDelete' => 'SET NULL'] |
1424
|
|
|
); |
1425
|
|
|
} |
1426
|
|
|
|
1427
|
|
|
/** |
1428
|
|
|
* Add orocrm_magento_newsl_subscr foreign keys. |
1429
|
|
|
* |
1430
|
|
|
* @param Schema $schema |
1431
|
|
|
*/ |
1432
|
|
View Code Duplication |
protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema) |
|
|
|
|
1433
|
|
|
{ |
1434
|
|
|
$table = $schema->getTable('orocrm_magento_newsl_subscr'); |
1435
|
|
|
$table->addForeignKeyConstraint( |
1436
|
|
|
$schema->getTable('oro_organization'), |
1437
|
|
|
['organization_id'], |
1438
|
|
|
['id'], |
1439
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1440
|
|
|
); |
1441
|
|
|
$table->addForeignKeyConstraint( |
1442
|
|
|
$schema->getTable('oro_user'), |
1443
|
|
|
['owner_id'], |
1444
|
|
|
['id'], |
1445
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1446
|
|
|
); |
1447
|
|
|
$table->addForeignKeyConstraint( |
1448
|
|
|
$schema->getTable('orocrm_magento_customer'), |
1449
|
|
|
['customer_id'], |
1450
|
|
|
['id'], |
1451
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1452
|
|
|
); |
1453
|
|
|
$table->addForeignKeyConstraint( |
1454
|
|
|
$schema->getTable('orocrm_magento_store'), |
1455
|
|
|
['store_id'], |
1456
|
|
|
['id'], |
1457
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1458
|
|
|
); |
1459
|
|
|
$table->addForeignKeyConstraint( |
1460
|
|
|
$schema->getTable('oro_integration_channel'), |
1461
|
|
|
['channel_id'], |
1462
|
|
|
['id'], |
1463
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1464
|
|
|
); |
1465
|
|
|
$table->addForeignKeyConstraint( |
1466
|
|
|
$schema->getTable('orocrm_channel'), |
1467
|
|
|
['data_channel_id'], |
1468
|
|
|
['id'], |
1469
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1470
|
|
|
); |
1471
|
|
|
} |
1472
|
|
|
|
1473
|
|
|
/** |
1474
|
|
|
* Enable activities |
1475
|
|
|
* |
1476
|
|
|
* @param Schema $schema |
1477
|
|
|
*/ |
1478
|
|
|
protected function addActivityAssociations(Schema $schema) |
1479
|
|
|
{ |
1480
|
|
|
$this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_magento_customer'); |
1481
|
|
|
$this->activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_magento_customer'); |
1482
|
|
|
|
1483
|
|
|
CreateActivityAssociation::addEmailAssociations($schema, $this->activityExtension); |
1484
|
|
|
OrderActivityAssociation::addActivityAssociations($schema, $this->activityExtension); |
1485
|
|
|
} |
1486
|
|
|
|
1487
|
|
|
/** |
1488
|
|
|
* @param Schema $schema |
1489
|
|
|
*/ |
1490
|
|
|
protected function addIdentifierEventAssociations(Schema $schema) |
1491
|
|
|
{ |
1492
|
|
|
$this->identifierEventExtension->addIdentifierAssociation($schema, 'orocrm_magento_customer'); |
1493
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_cart'); |
1494
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_customer'); |
1495
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_order'); |
1496
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_product'); |
1497
|
|
|
} |
1498
|
|
|
} |
1499
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.