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
|
|
|
$this->createOrocrmMagentoOrderCallsTable($schema); |
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
|
|
|
$this->createOrocrmMagentoCartCallsTable($schema); |
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
|
|
|
$this->addOrocrmMagentoOrderCallsForeignKeys($schema); |
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
|
|
|
$this->addOrocrmMagentoCartCallsForeignKeys($schema); |
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
|
|
|
* Create orocrm_magento_order_calls table |
345
|
|
|
* |
346
|
|
|
* @param Schema $schema |
347
|
|
|
*/ |
348
|
|
View Code Duplication |
protected function createOrocrmMagentoOrderCallsTable(Schema $schema) |
|
|
|
|
349
|
|
|
{ |
350
|
|
|
$table = $schema->createTable('orocrm_magento_order_calls'); |
351
|
|
|
$table->addColumn('order_id', 'integer', []); |
352
|
|
|
$table->addColumn('call_id', 'integer', []); |
353
|
|
|
$table->addIndex(['order_id'], 'IDX_A885A348D9F6D38', []); |
354
|
|
|
$table->addIndex(['call_id'], 'IDX_A885A3450A89B2C', []); |
355
|
|
|
$table->setPrimaryKey(['order_id', 'call_id']); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Create orocrm_magento_order_emails table |
360
|
|
|
* |
361
|
|
|
* @param Schema $schema |
362
|
|
|
*/ |
363
|
|
View Code Duplication |
protected function createOrocrmMagentoOrderEmailsTable(Schema $schema) |
|
|
|
|
364
|
|
|
{ |
365
|
|
|
$table = $schema->createTable('orocrm_magento_order_emails'); |
366
|
|
|
$table->addColumn('order_id', 'integer', []); |
367
|
|
|
$table->addColumn('email_id', 'integer', []); |
368
|
|
|
$table->addIndex(['order_id'], 'IDX_10E2A9508D9F6D38', []); |
369
|
|
|
$table->addIndex(['email_id'], 'IDX_10E2A950A832C1C9', []); |
370
|
|
|
$table->setPrimaryKey(['order_id', 'email_id']); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Create orocrm_magento_customer_group table |
375
|
|
|
* |
376
|
|
|
* @param Schema $schema |
377
|
|
|
*/ |
378
|
|
|
protected function createOrocrmMagentoCustomerGroupTable(Schema $schema) |
379
|
|
|
{ |
380
|
|
|
$table = $schema->createTable('orocrm_magento_customer_group'); |
381
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
382
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
383
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
384
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
385
|
|
|
$table->addIndex(['channel_id'], 'IDX_71E09CA872F5A1AA', []); |
386
|
|
|
$table->setPrimaryKey(['id']); |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Create orocrm_magento_customer table |
391
|
|
|
* |
392
|
|
|
* @param Schema $schema |
393
|
|
|
*/ |
394
|
|
|
protected function createOrocrmMagentoCustomerTable(Schema $schema) |
395
|
|
|
{ |
396
|
|
|
$table = $schema->createTable('orocrm_magento_customer'); |
397
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
398
|
|
|
$table->addColumn('website_id', 'integer', ['notnull' => false]); |
399
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
400
|
|
|
$table->addColumn('customer_group_id', 'integer', ['notnull' => false]); |
401
|
|
|
$table->addColumn('contact_id', 'integer', ['notnull' => false]); |
402
|
|
|
$table->addColumn('account_id', 'integer', ['notnull' => false]); |
403
|
|
|
$table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
404
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
405
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
406
|
|
|
$table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
407
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
408
|
|
|
$table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
409
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
410
|
|
|
$table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
411
|
|
|
$table->addColumn('gender', 'string', ['notnull' => false, 'length' => 8, 'precision' => 0]); |
412
|
|
|
$table->addColumn('birthday', 'date', ['notnull' => false, 'precision' => 0]); |
413
|
|
|
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
414
|
|
|
$table->addColumn('created_at', 'datetime', ['precision' => 0]); |
415
|
|
|
$table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
416
|
|
|
$table->addColumn('is_active', 'boolean', ['precision' => 0]); |
417
|
|
|
$table->addColumn('vat', 'string', ['notnull' => false, 'length' => 255]); |
418
|
|
|
$table->addColumn('lifetime', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
419
|
|
|
$table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]); |
420
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
421
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
422
|
|
|
$table->addColumn('rfm_recency', 'integer', ['notnull' => false]); |
423
|
|
|
$table->addColumn('rfm_frequency', 'integer', ['notnull' => false]); |
424
|
|
|
$table->addColumn('rfm_monetary', 'integer', ['notnull' => false]); |
425
|
|
|
$table->addColumn('sync_state', 'integer', ['notnull' => false]); |
426
|
|
|
$table->addColumn('password', 'string', ['notnull' => false, 'length' => 32]); |
427
|
|
|
$table->addColumn('created_in', 'string', ['notnull' => false, 'length' => 255]); |
428
|
|
|
$table->addColumn('is_confirmed', 'boolean', ['notnull' => false]); |
429
|
|
|
$table->addColumn('is_guest', 'boolean', ['notnull' => true, 'default' => false]); |
430
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
431
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
432
|
|
|
$table->addIndex(['website_id'], 'IDX_2A61EE7D18F45C82', []); |
433
|
|
|
$table->addIndex(['store_id'], 'IDX_2A61EE7DB092A811', []); |
434
|
|
|
$table->addIndex(['customer_group_id'], 'IDX_2A61EE7DD2919A68', []); |
435
|
|
|
$table->addIndex(['contact_id'], 'IDX_2A61EE7DE7A1254A', []); |
436
|
|
|
$table->addIndex(['account_id'], 'IDX_2A61EE7D9B6B5FBA', []); |
437
|
|
|
$table->addIndex(['user_owner_id'], 'IDX_2A61EE7D9EB185F9', []); |
438
|
|
|
$table->addIndex(['channel_id'], 'IDX_2A61EE7D72F5A1AA', []); |
439
|
|
|
$table->addIndex(['data_channel_id'], 'IDX_2A61EE7DBDC09B73', []); |
440
|
|
|
$table->addIndex(['organization_id'], 'IDX_2A61EE7D32C8A3DE', []); |
441
|
|
|
$table->setPrimaryKey(['id']); |
442
|
|
|
$table->addIndex(['first_name', 'last_name'], 'magecustomer_name_idx', []); |
443
|
|
|
$table->addIndex(['last_name', 'first_name'], 'magecustomer_rev_name_idx', []); |
444
|
|
|
$table->addIndex(['email'], 'magecustomer_email_guest_idx', []); |
445
|
|
|
$table->addUniqueIndex(['origin_id', 'channel_id'], 'magecustomer_oid_cid_unq'); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* Create orocrm_magento_cart_item table |
450
|
|
|
* |
451
|
|
|
* @param Schema $schema |
452
|
|
|
*/ |
453
|
|
|
protected function createOrocrmMagentoCartItemTable(Schema $schema) |
454
|
|
|
{ |
455
|
|
|
$table = $schema->createTable('orocrm_magento_cart_item'); |
456
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
457
|
|
|
$table->addColumn('cart_id', 'integer', ['notnull' => false]); |
458
|
|
|
$table->addColumn('product_id', 'integer', ['precision' => 0, 'unsigned' => true]); |
459
|
|
|
$table->addColumn('parent_item_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
460
|
|
|
$table->addColumn('free_shipping', 'string', ['length' => 255, 'precision' => 0]); |
461
|
|
|
$table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
462
|
|
|
$table->addColumn('tax_class_id', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
463
|
|
|
$table->addColumn('description', 'text', ['notnull' => false, 'precision' => 0]); |
464
|
|
|
$table->addColumn('is_virtual', 'boolean', ['precision' => 0]); |
465
|
|
|
$table->addColumn( |
466
|
|
|
'custom_price', |
467
|
|
|
'money', |
468
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
469
|
|
|
); |
470
|
|
|
$table->addColumn( |
471
|
|
|
'price_incl_tax', |
472
|
|
|
'money', |
473
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
474
|
|
|
); |
475
|
|
|
$table->addColumn('row_total', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
476
|
|
|
$table->addColumn('tax_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
477
|
|
|
$table->addColumn('product_type', 'string', ['length' => 255, 'precision' => 0]); |
478
|
|
|
$table->addColumn('product_image_url', 'text', ['notnull' => false]); |
479
|
|
|
$table->addColumn('product_url', 'text', ['notnull' => false]); |
480
|
|
|
$table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
481
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
482
|
|
|
$table->addColumn('qty', 'float', ['precision' => 0]); |
483
|
|
|
$table->addColumn('price', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
484
|
|
|
$table->addColumn('discount_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']); |
485
|
|
|
$table->addColumn('tax_percent', 'percent', ['precision' => 0, 'comment' => '(DC2Type:percent)']); |
486
|
|
|
$table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]); |
487
|
|
|
$table->addColumn('createdAt', 'datetime', ['precision' => 0]); |
488
|
|
|
$table->addColumn('updatedAt', 'datetime', ['precision' => 0]); |
489
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
490
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
491
|
|
|
$table->addColumn('is_removed', 'boolean', ['notnull' => true, 'default' => false]); |
492
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
493
|
|
|
$table->addIndex(['cart_id'], 'IDX_A73DC8621AD5CDBF', []); |
494
|
|
|
$table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []); |
495
|
|
|
$table->setPrimaryKey(['id']); |
496
|
|
|
$table->addIndex(['origin_id'], 'magecartitem_origin_idx', []); |
497
|
|
|
$table->addIndex(['sku'], 'magecartitem_sku_idx', []); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* Create orocrm_magento_customer_addr table |
502
|
|
|
* |
503
|
|
|
* @param Schema $schema |
504
|
|
|
*/ |
505
|
|
|
protected function createOrocrmMagentoCustomerAddrTable(Schema $schema) |
506
|
|
|
{ |
507
|
|
|
$table = $schema->createTable('orocrm_magento_customer_addr'); |
508
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
509
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
510
|
|
|
$table->addColumn('related_contact_address_id', 'integer', ['notnull' => false]); |
511
|
|
|
$table->addColumn('related_contact_phone_id', 'integer', ['notnull' => false]); |
512
|
|
|
$table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
513
|
|
|
$table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
514
|
|
|
$table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
515
|
|
|
$table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
516
|
|
|
$table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
517
|
|
|
$table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
518
|
|
|
$table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
519
|
|
|
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
520
|
|
|
$table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
521
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
522
|
|
|
$table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
523
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
524
|
|
|
$table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
525
|
|
|
$table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
526
|
|
|
$table->addColumn('is_primary', 'boolean', ['notnull' => false, 'precision' => 0]); |
527
|
|
|
$table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
528
|
|
|
$table->addColumn('created', 'datetime', ['precision' => 0]); |
529
|
|
|
$table->addColumn('updated', 'datetime', ['precision' => 0]); |
530
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
531
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
532
|
|
|
$table->addColumn('sync_state', 'integer', ['notnull' => false]); |
533
|
|
|
$table->addIndex(['owner_id'], 'IDX_1E239D647E3C61F9', []); |
534
|
|
|
$table->addUniqueIndex(['related_contact_address_id'], 'UNIQ_1E239D648137CB7B'); |
535
|
|
|
$table->addUniqueIndex(['related_contact_phone_id'], 'UNIQ_1E239D64E3694F65'); |
536
|
|
|
$table->addIndex(['country_code'], 'IDX_1E239D64F026BB7C', []); |
537
|
|
|
$table->addIndex(['region_code'], 'IDX_1E239D64AEB327AF', []); |
538
|
|
|
$table->setPrimaryKey(['id']); |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
/** |
542
|
|
|
* Create orocrm_magento_cust_addr_type table |
543
|
|
|
* |
544
|
|
|
* @param Schema $schema |
545
|
|
|
*/ |
546
|
|
View Code Duplication |
protected function createOrocrmMagentoCustAddrTypeTable(Schema $schema) |
|
|
|
|
547
|
|
|
{ |
548
|
|
|
$table = $schema->createTable('orocrm_magento_cust_addr_type'); |
549
|
|
|
$table->addColumn('customer_address_id', 'integer', []); |
550
|
|
|
$table->addColumn('type_name', 'string', ['length' => 16]); |
551
|
|
|
$table->addIndex(['customer_address_id'], 'IDX_308A31F187EABF7', []); |
552
|
|
|
$table->addIndex(['type_name'], 'IDX_308A31F1892CBB0E', []); |
553
|
|
|
$table->setPrimaryKey(['customer_address_id', 'type_name']); |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* Create orocrm_magento_order_address table |
558
|
|
|
* |
559
|
|
|
* @param Schema $schema |
560
|
|
|
*/ |
561
|
|
|
protected function createOrocrmMagentoOrderAddressTable(Schema $schema) |
562
|
|
|
{ |
563
|
|
|
$table = $schema->createTable('orocrm_magento_order_address'); |
564
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
565
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
566
|
|
|
$table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]); |
567
|
|
|
$table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]); |
568
|
|
|
$table->addColumn('fax', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
569
|
|
|
$table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
570
|
|
|
$table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]); |
571
|
|
|
$table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
572
|
|
|
$table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
573
|
|
|
$table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
574
|
|
|
$table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
575
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
576
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
577
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
578
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
579
|
|
|
$table->addIndex(['owner_id'], 'IDX_E31C6DEC7E3C61F9', []); |
580
|
|
|
$table->addIndex(['country_code'], 'IDX_E31C6DECF026BB7C', []); |
581
|
|
|
$table->addIndex(['region_code'], 'IDX_E31C6DECAEB327AF', []); |
582
|
|
|
$table->setPrimaryKey(['id']); |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* Create orocrm_magento_order_addr_type table |
587
|
|
|
* |
588
|
|
|
* @param Schema $schema |
589
|
|
|
*/ |
590
|
|
View Code Duplication |
protected function createOrocrmMagentoOrderAddrTypeTable(Schema $schema) |
|
|
|
|
591
|
|
|
{ |
592
|
|
|
$table = $schema->createTable('orocrm_magento_order_addr_type'); |
593
|
|
|
$table->addColumn('order_address_id', 'integer', []); |
594
|
|
|
$table->addColumn('type_name', 'string', ['length' => 16]); |
595
|
|
|
$table->addIndex(['order_address_id'], 'IDX_E927A18F466D5220', []); |
596
|
|
|
$table->addIndex(['type_name'], 'IDX_E927A18F892CBB0E', []); |
597
|
|
|
$table->setPrimaryKey(['order_address_id', 'type_name']); |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Create orocrm_magento_product table |
602
|
|
|
* |
603
|
|
|
* @param Schema $schema |
604
|
|
|
*/ |
605
|
|
|
protected function createOrocrmMagentoProductTable(Schema $schema) |
606
|
|
|
{ |
607
|
|
|
$table = $schema->createTable('orocrm_magento_product'); |
608
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
609
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
610
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
611
|
|
|
$table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
612
|
|
|
$table->addColumn('type', 'string', ['length' => 255, 'precision' => 0]); |
613
|
|
|
$table->addColumn( |
614
|
|
|
'special_price', |
615
|
|
|
'money', |
616
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
617
|
|
|
); |
618
|
|
|
$table->addColumn('price', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
619
|
|
|
$table->addColumn('created_at', 'datetime', ['precision' => 0]); |
620
|
|
|
$table->addColumn('updated_at', 'datetime', ['precision' => 0]); |
621
|
|
|
$table->addColumn('origin_id', 'integer', ['precision' => 0, 'unsigned' => true]); |
622
|
|
|
$table->addColumn('cost', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
623
|
|
|
$table->addIndex(['channel_id'], 'IDX_5A17298272F5A1AA', []); |
624
|
|
|
$table->setPrimaryKey(['id']); |
625
|
|
|
$table->addUniqueIndex(['sku', 'channel_id'], 'unq_sku_channel_id'); |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* Create orocrm_magento_prod_to_website table |
630
|
|
|
* |
631
|
|
|
* @param Schema $schema |
632
|
|
|
*/ |
633
|
|
View Code Duplication |
protected function createOrocrmMagentoProdToWebsiteTable(Schema $schema) |
|
|
|
|
634
|
|
|
{ |
635
|
|
|
$table = $schema->createTable('orocrm_magento_prod_to_website'); |
636
|
|
|
$table->addColumn('product_id', 'integer', []); |
637
|
|
|
$table->addColumn('website_id', 'integer', []); |
638
|
|
|
$table->addIndex(['product_id'], 'IDX_9BB836554584665A', []); |
639
|
|
|
$table->addIndex(['website_id'], 'IDX_9BB8365518F45C82', []); |
640
|
|
|
$table->setPrimaryKey(['product_id', 'website_id']); |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
/** |
644
|
|
|
* Create orocrm_magento_website table |
645
|
|
|
* |
646
|
|
|
* @param Schema $schema |
647
|
|
|
*/ |
648
|
|
|
protected function createOrocrmMagentoWebsiteTable(Schema $schema) |
649
|
|
|
{ |
650
|
|
|
$table = $schema->createTable('orocrm_magento_website'); |
651
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
652
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
653
|
|
|
$table->addColumn('website_code', 'string', ['length' => 32, 'precision' => 0]); |
654
|
|
|
$table->addColumn('website_name', 'string', ['length' => 255, 'precision' => 0]); |
655
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
656
|
|
|
$table->addColumn('sort_order', 'integer', ['notnull' => false]); |
657
|
|
|
$table->addColumn('is_default', 'boolean', ['notnull' => false]); |
658
|
|
|
$table->addColumn('default_group_id', 'integer', ['notnull' => false]); |
659
|
|
|
$table->addIndex(['channel_id'], 'IDX_CE3270C872F5A1AA', []); |
660
|
|
|
$table->setPrimaryKey(['id']); |
661
|
|
|
$table->addIndex(['website_name'], 'orocrm_magento_website_name_idx', []); |
662
|
|
|
$table->addUniqueIndex(['website_code', 'origin_id', 'channel_id'], 'unq_site_idx'); |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* Create orocrm_magento_cart table |
667
|
|
|
* |
668
|
|
|
* @param Schema $schema |
669
|
|
|
*/ |
670
|
|
|
protected function createOrocrmMagentoCartTable(Schema $schema) |
671
|
|
|
{ |
672
|
|
|
$table = $schema->createTable('orocrm_magento_cart'); |
673
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
674
|
|
|
$table->addColumn('customer_id', 'integer', ['notnull' => false]); |
675
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
676
|
|
|
$table->addColumn('shipping_address_id', 'integer', ['notnull' => false]); |
677
|
|
|
$table->addColumn('billing_address_id', 'integer', ['notnull' => false]); |
678
|
|
|
$table->addColumn('status_name', 'string', ['notnull' => false, 'length' => 32]); |
679
|
|
|
$table->addColumn('opportunity_id', 'integer', ['notnull' => false]); |
680
|
|
|
$table->addColumn('workflow_item_id', 'integer', ['notnull' => false]); |
681
|
|
|
$table->addColumn('workflow_step_id', 'integer', ['notnull' => false]); |
682
|
|
|
$table->addColumn('user_owner_id', 'integer', ['notnull' => false]); |
683
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
684
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
685
|
|
|
$table->addColumn('items_qty', 'float', ['precision' => 0]); |
686
|
|
|
$table->addColumn('items_count', 'integer', ['precision' => 0, 'unsigned' => true]); |
687
|
|
|
$table->addColumn('base_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
688
|
|
|
$table->addColumn('store_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
689
|
|
|
$table->addColumn('quote_currency_code', 'string', ['length' => 32, 'precision' => 0]); |
690
|
|
|
$table->addColumn('store_to_base_rate', 'float', ['precision' => 0]); |
691
|
|
|
$table->addColumn('store_to_quote_rate', 'float', ['notnull' => false, 'precision' => 0]); |
692
|
|
|
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
693
|
|
|
$table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
694
|
|
|
$table->addColumn('is_guest', 'boolean', ['precision' => 0]); |
695
|
|
|
$table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
696
|
|
|
$table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]); |
697
|
|
|
$table->addColumn('status_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
698
|
|
|
$table->addColumn('sub_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
699
|
|
|
$table->addColumn( |
700
|
|
|
'grand_total', |
701
|
|
|
'money', |
702
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
703
|
|
|
); |
704
|
|
|
$table->addColumn( |
705
|
|
|
'tax_amount', |
706
|
|
|
'money', |
707
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
708
|
|
|
); |
709
|
|
|
$table->addColumn('createdAt', 'datetime', ['precision' => 0]); |
710
|
|
|
$table->addColumn('updatedAt', 'datetime', ['precision' => 0]); |
711
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
712
|
|
|
$table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
713
|
|
|
$table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
714
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
715
|
|
|
$table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
716
|
|
|
$table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
717
|
|
|
$table->addIndex(['customer_id'], 'IDX_96661A809395C3F3', []); |
718
|
|
|
$table->addIndex(['store_id'], 'IDX_96661A80B092A811', []); |
719
|
|
|
$table->addIndex(['shipping_address_id'], 'IDX_96661A804D4CFF2B', []); |
720
|
|
|
$table->addIndex(['billing_address_id'], 'IDX_96661A8079D0C0E4', []); |
721
|
|
|
$table->addIndex(['status_name'], 'IDX_96661A806625D392', []); |
722
|
|
|
$table->addIndex(['opportunity_id'], 'IDX_96661A809A34590F', []); |
723
|
|
|
$table->addUniqueIndex(['workflow_item_id'], 'UNIQ_96661A801023C4EE'); |
724
|
|
|
$table->addIndex(['workflow_step_id'], 'IDX_96661A8071FE882C', []); |
725
|
|
|
$table->addIndex(['user_owner_id'], 'IDX_96661A809EB185F9', []); |
726
|
|
|
$table->addIndex(['channel_id'], 'IDX_96661A8072F5A1AA', []); |
727
|
|
|
$table->addIndex(['data_channel_id'], 'IDX_96661A80BDC09B73', []); |
728
|
|
|
$table->addIndex(['organization_id'], 'IDX_96661A8032C8A3DE', []); |
729
|
|
|
$table->setPrimaryKey(['id']); |
730
|
|
|
$table->addIndex(['origin_id'], 'magecart_origin_idx', []); |
731
|
|
|
$table->addIndex(['updatedAt'], 'magecart_updated_idx', []); |
732
|
|
|
$table->addUniqueIndex(['origin_id', 'channel_id'], 'unq_cart_origin_id_channel_id'); |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* Create orocrm_magento_cart_calls table |
737
|
|
|
* |
738
|
|
|
* @param Schema $schema |
739
|
|
|
*/ |
740
|
|
View Code Duplication |
protected function createOrocrmMagentoCartCallsTable(Schema $schema) |
|
|
|
|
741
|
|
|
{ |
742
|
|
|
$table = $schema->createTable('orocrm_magento_cart_calls'); |
743
|
|
|
$table->addColumn('cart_id', 'integer', []); |
744
|
|
|
$table->addColumn('call_id', 'integer', []); |
745
|
|
|
$table->addIndex(['cart_id'], 'IDX_83A847751AD5CDBF', []); |
746
|
|
|
$table->addIndex(['call_id'], 'IDX_83A8477550A89B2C', []); |
747
|
|
|
$table->setPrimaryKey(['cart_id', 'call_id']); |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
/** |
751
|
|
|
* Create orocrm_magento_cart_emails table |
752
|
|
|
* |
753
|
|
|
* @param Schema $schema |
754
|
|
|
*/ |
755
|
|
View Code Duplication |
protected function createOrocrmMagentoCartEmailsTable(Schema $schema) |
|
|
|
|
756
|
|
|
{ |
757
|
|
|
$table = $schema->createTable('orocrm_magento_cart_emails'); |
758
|
|
|
$table->addColumn('cart_id', 'integer', []); |
759
|
|
|
$table->addColumn('email_id', 'integer', []); |
760
|
|
|
$table->addIndex(['cart_id'], 'IDX_11B0F84B1AD5CDBF', []); |
761
|
|
|
$table->addIndex(['email_id'], 'IDX_11B0F84BA832C1C9', []); |
762
|
|
|
$table->setPrimaryKey(['cart_id', 'email_id']); |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
/** |
766
|
|
|
* Create orocrm_magento_store table |
767
|
|
|
* |
768
|
|
|
* @param Schema $schema |
769
|
|
|
*/ |
770
|
|
View Code Duplication |
protected function createOrocrmMagentoStoreTable(Schema $schema) |
|
|
|
|
771
|
|
|
{ |
772
|
|
|
$table = $schema->createTable('orocrm_magento_store'); |
773
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
774
|
|
|
$table->addColumn('website_id', 'integer', []); |
775
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
776
|
|
|
$table->addColumn('store_code', 'string', ['length' => 32, 'precision' => 0]); |
777
|
|
|
$table->addColumn('store_name', 'string', ['length' => 255, 'precision' => 0]); |
778
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
779
|
|
|
$table->addIndex(['website_id'], 'IDX_477738EA18F45C82', []); |
780
|
|
|
$table->addIndex(['channel_id'], 'IDX_477738EA72F5A1AA', []); |
781
|
|
|
$table->setPrimaryKey(['id']); |
782
|
|
|
$table->addUniqueIndex(['store_code', 'channel_id'], 'unq_code_channel_id'); |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
/** |
786
|
|
|
* Create orocrm_magento_cart_status table |
787
|
|
|
* |
788
|
|
|
* @param Schema $schema |
789
|
|
|
*/ |
790
|
|
|
protected function createOrocrmMagentoCartStatusTable(Schema $schema) |
791
|
|
|
{ |
792
|
|
|
$table = $schema->createTable('orocrm_magento_cart_status'); |
793
|
|
|
$table->addColumn('name', 'string', ['length' => 32, 'precision' => 0]); |
794
|
|
|
$table->addColumn('label', 'string', ['length' => 255, 'precision' => 0]); |
795
|
|
|
$table->addUniqueIndex(['label'], 'UNIQ_26317505EA750E8'); |
796
|
|
|
$table->setPrimaryKey(['name']); |
797
|
|
|
} |
798
|
|
|
|
799
|
|
|
/** |
800
|
|
|
* Create orocrm_magento_order_items table |
801
|
|
|
* |
802
|
|
|
* @param Schema $schema |
803
|
|
|
*/ |
804
|
|
|
protected function createOrocrmMagentoOrderItemsTable(Schema $schema) |
805
|
|
|
{ |
806
|
|
|
$table = $schema->createTable('orocrm_magento_order_items'); |
807
|
|
|
$table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]); |
808
|
|
|
$table->addColumn('order_id', 'integer', ['notnull' => false]); |
809
|
|
|
$table->addColumn('product_type', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]); |
810
|
|
|
$table->addColumn('product_options', 'text', ['notnull' => false, 'precision' => 0]); |
811
|
|
|
$table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]); |
812
|
|
|
$table->addColumn( |
813
|
|
|
'original_price', |
814
|
|
|
'money', |
815
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
816
|
|
|
); |
817
|
|
|
$table->addColumn( |
818
|
|
|
'discount_percent', |
819
|
|
|
'percent', |
820
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
821
|
|
|
); |
822
|
|
|
$table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]); |
823
|
|
|
$table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0]); |
824
|
|
|
$table->addColumn('qty', 'float', ['precision' => 0]); |
825
|
|
|
$table->addColumn('price', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
826
|
|
|
$table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]); |
827
|
|
|
$table->addColumn( |
828
|
|
|
'tax_percent', |
829
|
|
|
'percent', |
830
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)'] |
831
|
|
|
); |
832
|
|
|
$table->addColumn( |
833
|
|
|
'tax_amount', |
834
|
|
|
'money', |
835
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
836
|
|
|
); |
837
|
|
|
$table->addColumn( |
838
|
|
|
'discount_amount', |
839
|
|
|
'money', |
840
|
|
|
['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)'] |
841
|
|
|
); |
842
|
|
|
$table->addColumn('row_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']); |
843
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
844
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
845
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
846
|
|
|
$table->addIndex(['order_id'], 'IDX_3135EFF68D9F6D38', []); |
847
|
|
|
$table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []); |
848
|
|
|
$table->setPrimaryKey(['id']); |
849
|
|
|
} |
850
|
|
|
|
851
|
|
|
/** |
852
|
|
|
* Create orocrm_magento_newsl_subscr table |
853
|
|
|
* |
854
|
|
|
* @param Schema $schema |
855
|
|
|
*/ |
856
|
|
|
protected function createOrocrmMagentoNewslSubscrTable(Schema $schema) |
857
|
|
|
{ |
858
|
|
|
$table = $schema->createTable('orocrm_magento_newsl_subscr'); |
859
|
|
|
$table->addColumn('id', 'integer', ['autoincrement' => true]); |
860
|
|
|
$table->addColumn('organization_id', 'integer', ['notnull' => false]); |
861
|
|
|
$table->addColumn('owner_id', 'integer', ['notnull' => false]); |
862
|
|
|
$table->addColumn('customer_id', 'integer', ['notnull' => false]); |
863
|
|
|
$table->addColumn('store_id', 'integer', ['notnull' => false]); |
864
|
|
|
$table->addColumn('channel_id', 'integer', ['notnull' => false]); |
865
|
|
|
$table->addColumn('data_channel_id', 'integer', ['notnull' => false]); |
866
|
|
|
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]); |
867
|
|
|
$table->addColumn('change_status_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']); |
868
|
|
|
$table->addColumn('created_at', 'datetime', ['comment' => '(DC2Type:datetime)']); |
869
|
|
|
$table->addColumn('updated_at', 'datetime', ['comment' => '(DC2Type:datetime)']); |
870
|
|
|
$table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]); |
871
|
|
|
$table->addColumn('confirm_code', 'string', ['notnull' => false, 'length' => 32]); |
872
|
|
|
$table->setPrimaryKey(['id']); |
873
|
|
|
|
874
|
|
|
$this->extendExtension->addEnumField( |
875
|
|
|
$schema, |
876
|
|
|
$table, |
877
|
|
|
'status', |
878
|
|
|
'mage_subscr_status', |
879
|
|
|
false, |
880
|
|
|
false, |
881
|
|
|
[ |
882
|
|
|
'extend' => ['owner' => ExtendScope::OWNER_CUSTOM] |
883
|
|
|
] |
884
|
|
|
); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
/** |
888
|
|
|
* Add orocrm_magento_cart_address foreign keys. |
889
|
|
|
* |
890
|
|
|
* @param Schema $schema |
891
|
|
|
*/ |
892
|
|
|
protected function addOrocrmMagentoCartAddressForeignKeys(Schema $schema) |
893
|
|
|
{ |
894
|
|
|
$table = $schema->getTable('orocrm_magento_cart_address'); |
895
|
|
|
$table->addForeignKeyConstraint( |
896
|
|
|
$schema->getTable('oro_dictionary_country'), |
897
|
|
|
['country_code'], |
898
|
|
|
['iso2_code'], |
899
|
|
|
[] |
900
|
|
|
); |
901
|
|
|
$table->addForeignKeyConstraint( |
902
|
|
|
$schema->getTable('oro_dictionary_region'), |
903
|
|
|
['region_code'], |
904
|
|
|
['combined_code'], |
905
|
|
|
[] |
906
|
|
|
); |
907
|
|
|
$table->addForeignKeyConstraint( |
908
|
|
|
$schema->getTable('oro_integration_channel'), |
909
|
|
|
['channel_id'], |
910
|
|
|
['id'], |
911
|
|
|
['onDelete' => 'SET NULL'] |
912
|
|
|
); |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
/** |
916
|
|
|
* Add orocrm_magento_order foreign keys. |
917
|
|
|
* |
918
|
|
|
* @param Schema $schema |
919
|
|
|
*/ |
920
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderForeignKeys(Schema $schema) |
|
|
|
|
921
|
|
|
{ |
922
|
|
|
$table = $schema->getTable('orocrm_magento_order'); |
923
|
|
|
$table->addForeignKeyConstraint( |
924
|
|
|
$schema->getTable('orocrm_magento_customer'), |
925
|
|
|
['customer_id'], |
926
|
|
|
['id'], |
927
|
|
|
['onDelete' => 'SET NULL'] |
928
|
|
|
); |
929
|
|
|
$table->addForeignKeyConstraint( |
930
|
|
|
$schema->getTable('orocrm_magento_store'), |
931
|
|
|
['store_id'], |
932
|
|
|
['id'], |
933
|
|
|
['onDelete' => 'SET NULL'] |
934
|
|
|
); |
935
|
|
|
$table->addForeignKeyConstraint( |
936
|
|
|
$schema->getTable('orocrm_magento_cart'), |
937
|
|
|
['cart_id'], |
938
|
|
|
['id'], |
939
|
|
|
[] |
940
|
|
|
); |
941
|
|
|
$table->addForeignKeyConstraint( |
942
|
|
|
$schema->getTable('oro_workflow_item'), |
943
|
|
|
['workflow_item_id'], |
944
|
|
|
['id'], |
945
|
|
|
['onDelete' => 'SET NULL'] |
946
|
|
|
); |
947
|
|
|
$table->addForeignKeyConstraint( |
948
|
|
|
$schema->getTable('oro_workflow_step'), |
949
|
|
|
['workflow_step_id'], |
950
|
|
|
['id'], |
951
|
|
|
['onDelete' => 'SET NULL'] |
952
|
|
|
); |
953
|
|
|
$table->addForeignKeyConstraint( |
954
|
|
|
$schema->getTable('oro_user'), |
955
|
|
|
['user_owner_id'], |
956
|
|
|
['id'], |
957
|
|
|
['onDelete' => 'SET NULL'] |
958
|
|
|
); |
959
|
|
|
$table->addForeignKeyConstraint( |
960
|
|
|
$schema->getTable('oro_integration_channel'), |
961
|
|
|
['channel_id'], |
962
|
|
|
['id'], |
963
|
|
|
['onDelete' => 'SET NULL'] |
964
|
|
|
); |
965
|
|
|
$table->addForeignKeyConstraint( |
966
|
|
|
$schema->getTable('orocrm_channel'), |
967
|
|
|
['data_channel_id'], |
968
|
|
|
['id'], |
969
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
970
|
|
|
'FK_4D09F305BDC09B73' |
971
|
|
|
); |
972
|
|
|
$table->addForeignKeyConstraint( |
973
|
|
|
$schema->getTable('oro_organization'), |
974
|
|
|
['organization_id'], |
975
|
|
|
['id'], |
976
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
977
|
|
|
'FK_4D09F30532C8A3DE' |
978
|
|
|
); |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
/** |
982
|
|
|
* Add orocrm_magento_order_calls foreign keys. |
983
|
|
|
* |
984
|
|
|
* @param Schema $schema |
985
|
|
|
*/ |
986
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderCallsForeignKeys(Schema $schema) |
|
|
|
|
987
|
|
|
{ |
988
|
|
|
$table = $schema->getTable('orocrm_magento_order_calls'); |
989
|
|
|
$table->addForeignKeyConstraint( |
990
|
|
|
$schema->getTable('orocrm_magento_order'), |
991
|
|
|
['order_id'], |
992
|
|
|
['id'], |
993
|
|
|
['onDelete' => 'CASCADE'] |
994
|
|
|
); |
995
|
|
|
$table->addForeignKeyConstraint( |
996
|
|
|
$schema->getTable('orocrm_call'), |
997
|
|
|
['call_id'], |
998
|
|
|
['id'], |
999
|
|
|
['onDelete' => 'CASCADE'] |
1000
|
|
|
); |
1001
|
|
|
} |
1002
|
|
|
|
1003
|
|
|
/** |
1004
|
|
|
* Add orocrm_magento_order_emails foreign keys. |
1005
|
|
|
* |
1006
|
|
|
* @param Schema $schema |
1007
|
|
|
*/ |
1008
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderEmailsForeignKeys(Schema $schema) |
|
|
|
|
1009
|
|
|
{ |
1010
|
|
|
$table = $schema->getTable('orocrm_magento_order_emails'); |
1011
|
|
|
$table->addForeignKeyConstraint( |
1012
|
|
|
$schema->getTable('orocrm_magento_order'), |
1013
|
|
|
['order_id'], |
1014
|
|
|
['id'], |
1015
|
|
|
['onDelete' => 'CASCADE'] |
1016
|
|
|
); |
1017
|
|
|
$table->addForeignKeyConstraint( |
1018
|
|
|
$schema->getTable('oro_email'), |
1019
|
|
|
['email_id'], |
1020
|
|
|
['id'], |
1021
|
|
|
['onDelete' => 'CASCADE'] |
1022
|
|
|
); |
1023
|
|
|
} |
1024
|
|
|
|
1025
|
|
|
/** |
1026
|
|
|
* Add orocrm_magento_customer_group foreign keys. |
1027
|
|
|
* |
1028
|
|
|
* @param Schema $schema |
1029
|
|
|
*/ |
1030
|
|
View Code Duplication |
protected function addOrocrmMagentoCustomerGroupForeignKeys(Schema $schema) |
|
|
|
|
1031
|
|
|
{ |
1032
|
|
|
$table = $schema->getTable('orocrm_magento_customer_group'); |
1033
|
|
|
$table->addForeignKeyConstraint( |
1034
|
|
|
$schema->getTable('oro_integration_channel'), |
1035
|
|
|
['channel_id'], |
1036
|
|
|
['id'], |
1037
|
|
|
['onDelete' => 'SET NULL'] |
1038
|
|
|
); |
1039
|
|
|
} |
1040
|
|
|
|
1041
|
|
|
/** |
1042
|
|
|
* Add orocrm_magento_customer foreign keys. |
1043
|
|
|
* |
1044
|
|
|
* @param Schema $schema |
1045
|
|
|
*/ |
1046
|
|
View Code Duplication |
protected function addOrocrmMagentoCustomerForeignKeys(Schema $schema) |
|
|
|
|
1047
|
|
|
{ |
1048
|
|
|
$table = $schema->getTable('orocrm_magento_customer'); |
1049
|
|
|
$table->addForeignKeyConstraint( |
1050
|
|
|
$schema->getTable('orocrm_magento_website'), |
1051
|
|
|
['website_id'], |
1052
|
|
|
['id'], |
1053
|
|
|
['onDelete' => 'SET NULL'] |
1054
|
|
|
); |
1055
|
|
|
$table->addForeignKeyConstraint( |
1056
|
|
|
$schema->getTable('orocrm_magento_store'), |
1057
|
|
|
['store_id'], |
1058
|
|
|
['id'], |
1059
|
|
|
['onDelete' => 'SET NULL'] |
1060
|
|
|
); |
1061
|
|
|
$table->addForeignKeyConstraint( |
1062
|
|
|
$schema->getTable('orocrm_magento_customer_group'), |
1063
|
|
|
['customer_group_id'], |
1064
|
|
|
['id'], |
1065
|
|
|
['onDelete' => 'SET NULL'] |
1066
|
|
|
); |
1067
|
|
|
$table->addForeignKeyConstraint( |
1068
|
|
|
$schema->getTable('orocrm_contact'), |
1069
|
|
|
['contact_id'], |
1070
|
|
|
['id'], |
1071
|
|
|
['onDelete' => 'SET NULL'] |
1072
|
|
|
); |
1073
|
|
|
$table->addForeignKeyConstraint( |
1074
|
|
|
$schema->getTable('orocrm_account'), |
1075
|
|
|
['account_id'], |
1076
|
|
|
['id'], |
1077
|
|
|
['onDelete' => 'SET NULL'] |
1078
|
|
|
); |
1079
|
|
|
$table->addForeignKeyConstraint( |
1080
|
|
|
$schema->getTable('oro_user'), |
1081
|
|
|
['user_owner_id'], |
1082
|
|
|
['id'], |
1083
|
|
|
['onDelete' => 'SET NULL'] |
1084
|
|
|
); |
1085
|
|
|
$table->addForeignKeyConstraint( |
1086
|
|
|
$schema->getTable('oro_integration_channel'), |
1087
|
|
|
['channel_id'], |
1088
|
|
|
['id'], |
1089
|
|
|
['onDelete' => 'SET NULL'] |
1090
|
|
|
); |
1091
|
|
|
$table->addForeignKeyConstraint( |
1092
|
|
|
$schema->getTable('orocrm_channel'), |
1093
|
|
|
['data_channel_id'], |
1094
|
|
|
['id'], |
1095
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1096
|
|
|
'FK_2A61EE7DBDC09B73' |
1097
|
|
|
); |
1098
|
|
|
$table->addForeignKeyConstraint( |
1099
|
|
|
$schema->getTable('oro_organization'), |
1100
|
|
|
['organization_id'], |
1101
|
|
|
['id'], |
1102
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1103
|
|
|
'FK_2A61EE7D32C8A3DE' |
1104
|
|
|
); |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
/** |
1108
|
|
|
* Add orocrm_magento_cart_item foreign keys. |
1109
|
|
|
* |
1110
|
|
|
* @param Schema $schema |
1111
|
|
|
*/ |
1112
|
|
View Code Duplication |
protected function addOrocrmMagentoCartItemForeignKeys(Schema $schema) |
|
|
|
|
1113
|
|
|
{ |
1114
|
|
|
$table = $schema->getTable('orocrm_magento_cart_item'); |
1115
|
|
|
$table->addForeignKeyConstraint( |
1116
|
|
|
$schema->getTable('orocrm_magento_cart'), |
1117
|
|
|
['cart_id'], |
1118
|
|
|
['id'], |
1119
|
|
|
['onDelete' => 'CASCADE'] |
1120
|
|
|
); |
1121
|
|
|
$table->addForeignKeyConstraint( |
1122
|
|
|
$schema->getTable('oro_integration_channel'), |
1123
|
|
|
['channel_id'], |
1124
|
|
|
['id'], |
1125
|
|
|
['onDelete' => 'SET NULL'] |
1126
|
|
|
); |
1127
|
|
|
$table->addForeignKeyConstraint( |
1128
|
|
|
$schema->getTable('oro_organization'), |
1129
|
|
|
['owner_id'], |
1130
|
|
|
['id'], |
1131
|
|
|
['onDelete' => 'SET NULL'] |
1132
|
|
|
); |
1133
|
|
|
} |
1134
|
|
|
|
1135
|
|
|
/** |
1136
|
|
|
* Add orocrm_magento_customer_addr foreign keys. |
1137
|
|
|
* |
1138
|
|
|
* @param Schema $schema |
1139
|
|
|
*/ |
1140
|
|
|
protected function addOrocrmMagentoCustomerAddrForeignKeys(Schema $schema) |
1141
|
|
|
{ |
1142
|
|
|
$table = $schema->getTable('orocrm_magento_customer_addr'); |
1143
|
|
|
$table->addForeignKeyConstraint( |
1144
|
|
|
$schema->getTable('orocrm_magento_customer'), |
1145
|
|
|
['owner_id'], |
1146
|
|
|
['id'], |
1147
|
|
|
['onDelete' => 'CASCADE'] |
1148
|
|
|
); |
1149
|
|
|
$table->addForeignKeyConstraint( |
1150
|
|
|
$schema->getTable('orocrm_contact_address'), |
1151
|
|
|
['related_contact_address_id'], |
1152
|
|
|
['id'], |
1153
|
|
|
['onDelete' => 'SET NULL'] |
1154
|
|
|
); |
1155
|
|
|
$table->addForeignKeyConstraint( |
1156
|
|
|
$schema->getTable('orocrm_contact_phone'), |
1157
|
|
|
['related_contact_phone_id'], |
1158
|
|
|
['id'], |
1159
|
|
|
['onDelete' => 'SET NULL'] |
1160
|
|
|
); |
1161
|
|
|
$table->addForeignKeyConstraint( |
1162
|
|
|
$schema->getTable('oro_dictionary_country'), |
1163
|
|
|
['country_code'], |
1164
|
|
|
['iso2_code'], |
1165
|
|
|
[] |
1166
|
|
|
); |
1167
|
|
|
$table->addForeignKeyConstraint( |
1168
|
|
|
$schema->getTable('oro_dictionary_region'), |
1169
|
|
|
['region_code'], |
1170
|
|
|
['combined_code'], |
1171
|
|
|
[] |
1172
|
|
|
); |
1173
|
|
|
$table->addForeignKeyConstraint( |
1174
|
|
|
$schema->getTable('oro_integration_channel'), |
1175
|
|
|
['channel_id'], |
1176
|
|
|
['id'], |
1177
|
|
|
['onDelete' => 'SET NULL'] |
1178
|
|
|
); |
1179
|
|
|
} |
1180
|
|
|
|
1181
|
|
|
/** |
1182
|
|
|
* Add orocrm_magento_cust_addr_type foreign keys. |
1183
|
|
|
* |
1184
|
|
|
* @param Schema $schema |
1185
|
|
|
*/ |
1186
|
|
View Code Duplication |
protected function addOrocrmMagentoCustAddrTypeForeignKeys(Schema $schema) |
|
|
|
|
1187
|
|
|
{ |
1188
|
|
|
$table = $schema->getTable('orocrm_magento_cust_addr_type'); |
1189
|
|
|
$table->addForeignKeyConstraint( |
1190
|
|
|
$schema->getTable('orocrm_magento_customer_addr'), |
1191
|
|
|
['customer_address_id'], |
1192
|
|
|
['id'], |
1193
|
|
|
['onDelete' => 'CASCADE'], |
1194
|
|
|
'FK_308A31F187EABF7' |
1195
|
|
|
); |
1196
|
|
|
$table->addForeignKeyConstraint( |
1197
|
|
|
$schema->getTable('oro_address_type'), |
1198
|
|
|
['type_name'], |
1199
|
|
|
['name'], |
1200
|
|
|
[] |
1201
|
|
|
); |
1202
|
|
|
} |
1203
|
|
|
|
1204
|
|
|
/** |
1205
|
|
|
* Add orocrm_magento_order_address foreign keys. |
1206
|
|
|
* |
1207
|
|
|
* @param Schema $schema |
1208
|
|
|
*/ |
1209
|
|
|
protected function addOrocrmMagentoOrderAddressForeignKeys(Schema $schema) |
1210
|
|
|
{ |
1211
|
|
|
$table = $schema->getTable('orocrm_magento_order_address'); |
1212
|
|
|
$table->addForeignKeyConstraint( |
1213
|
|
|
$schema->getTable('orocrm_magento_order'), |
1214
|
|
|
['owner_id'], |
1215
|
|
|
['id'], |
1216
|
|
|
['onDelete' => 'CASCADE'] |
1217
|
|
|
); |
1218
|
|
|
$table->addForeignKeyConstraint( |
1219
|
|
|
$schema->getTable('oro_dictionary_country'), |
1220
|
|
|
['country_code'], |
1221
|
|
|
['iso2_code'], |
1222
|
|
|
[] |
1223
|
|
|
); |
1224
|
|
|
$table->addForeignKeyConstraint( |
1225
|
|
|
$schema->getTable('oro_dictionary_region'), |
1226
|
|
|
['region_code'], |
1227
|
|
|
['combined_code'], |
1228
|
|
|
[] |
1229
|
|
|
); |
1230
|
|
|
$table->addForeignKeyConstraint( |
1231
|
|
|
$schema->getTable('oro_integration_channel'), |
1232
|
|
|
['channel_id'], |
1233
|
|
|
['id'], |
1234
|
|
|
['onDelete' => 'SET NULL'] |
1235
|
|
|
); |
1236
|
|
|
} |
1237
|
|
|
|
1238
|
|
|
/** |
1239
|
|
|
* Add orocrm_magento_order_addr_type foreign keys. |
1240
|
|
|
* |
1241
|
|
|
* @param Schema $schema |
1242
|
|
|
*/ |
1243
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderAddrTypeForeignKeys(Schema $schema) |
|
|
|
|
1244
|
|
|
{ |
1245
|
|
|
$table = $schema->getTable('orocrm_magento_order_addr_type'); |
1246
|
|
|
$table->addForeignKeyConstraint( |
1247
|
|
|
$schema->getTable('orocrm_magento_order_address'), |
1248
|
|
|
['order_address_id'], |
1249
|
|
|
['id'], |
1250
|
|
|
['onDelete' => 'CASCADE'], |
1251
|
|
|
'FK_E927A18F466D5220' |
1252
|
|
|
); |
1253
|
|
|
$table->addForeignKeyConstraint( |
1254
|
|
|
$schema->getTable('oro_address_type'), |
1255
|
|
|
['type_name'], |
1256
|
|
|
['name'], |
1257
|
|
|
[] |
1258
|
|
|
); |
1259
|
|
|
} |
1260
|
|
|
|
1261
|
|
|
/** |
1262
|
|
|
* Add orocrm_magento_product foreign keys. |
1263
|
|
|
* |
1264
|
|
|
* @param Schema $schema |
1265
|
|
|
*/ |
1266
|
|
View Code Duplication |
protected function addOrocrmMagentoProductForeignKeys(Schema $schema) |
|
|
|
|
1267
|
|
|
{ |
1268
|
|
|
$table = $schema->getTable('orocrm_magento_product'); |
1269
|
|
|
$table->addForeignKeyConstraint( |
1270
|
|
|
$schema->getTable('oro_integration_channel'), |
1271
|
|
|
['channel_id'], |
1272
|
|
|
['id'], |
1273
|
|
|
['onDelete' => 'SET NULL'] |
1274
|
|
|
); |
1275
|
|
|
} |
1276
|
|
|
|
1277
|
|
|
/** |
1278
|
|
|
* Add orocrm_magento_prod_to_website foreign keys. |
1279
|
|
|
* |
1280
|
|
|
* @param Schema $schema |
1281
|
|
|
*/ |
1282
|
|
View Code Duplication |
protected function addOrocrmMagentoProdToWebsiteForeignKeys(Schema $schema) |
|
|
|
|
1283
|
|
|
{ |
1284
|
|
|
$table = $schema->getTable('orocrm_magento_prod_to_website'); |
1285
|
|
|
$table->addForeignKeyConstraint( |
1286
|
|
|
$schema->getTable('orocrm_magento_product'), |
1287
|
|
|
['product_id'], |
1288
|
|
|
['id'], |
1289
|
|
|
['onDelete' => 'CASCADE'] |
1290
|
|
|
); |
1291
|
|
|
$table->addForeignKeyConstraint( |
1292
|
|
|
$schema->getTable('orocrm_magento_website'), |
1293
|
|
|
['website_id'], |
1294
|
|
|
['id'], |
1295
|
|
|
['onDelete' => 'CASCADE'] |
1296
|
|
|
); |
1297
|
|
|
} |
1298
|
|
|
|
1299
|
|
|
/** |
1300
|
|
|
* Add orocrm_magento_website foreign keys. |
1301
|
|
|
* |
1302
|
|
|
* @param Schema $schema |
1303
|
|
|
*/ |
1304
|
|
View Code Duplication |
protected function addOrocrmMagentoWebsiteForeignKeys(Schema $schema) |
|
|
|
|
1305
|
|
|
{ |
1306
|
|
|
$table = $schema->getTable('orocrm_magento_website'); |
1307
|
|
|
$table->addForeignKeyConstraint( |
1308
|
|
|
$schema->getTable('oro_integration_channel'), |
1309
|
|
|
['channel_id'], |
1310
|
|
|
['id'], |
1311
|
|
|
['onDelete' => 'SET NULL'] |
1312
|
|
|
); |
1313
|
|
|
} |
1314
|
|
|
|
1315
|
|
|
/** |
1316
|
|
|
* Add orocrm_magento_cart foreign keys. |
1317
|
|
|
* |
1318
|
|
|
* @param Schema $schema |
1319
|
|
|
*/ |
1320
|
|
|
protected function addOrocrmMagentoCartForeignKeys(Schema $schema) |
1321
|
|
|
{ |
1322
|
|
|
$table = $schema->getTable('orocrm_magento_cart'); |
1323
|
|
|
$table->addForeignKeyConstraint( |
1324
|
|
|
$schema->getTable('orocrm_magento_customer'), |
1325
|
|
|
['customer_id'], |
1326
|
|
|
['id'], |
1327
|
|
|
['onDelete' => 'CASCADE'] |
1328
|
|
|
); |
1329
|
|
|
$table->addForeignKeyConstraint( |
1330
|
|
|
$schema->getTable('orocrm_magento_store'), |
1331
|
|
|
['store_id'], |
1332
|
|
|
['id'], |
1333
|
|
|
['onDelete' => 'SET NULL'] |
1334
|
|
|
); |
1335
|
|
|
$table->addForeignKeyConstraint( |
1336
|
|
|
$schema->getTable('orocrm_magento_cart_address'), |
1337
|
|
|
['shipping_address_id'], |
1338
|
|
|
['id'], |
1339
|
|
|
['onDelete' => 'SET NULL'] |
1340
|
|
|
); |
1341
|
|
|
$table->addForeignKeyConstraint( |
1342
|
|
|
$schema->getTable('orocrm_magento_cart_address'), |
1343
|
|
|
['billing_address_id'], |
1344
|
|
|
['id'], |
1345
|
|
|
['onDelete' => 'SET NULL'] |
1346
|
|
|
); |
1347
|
|
|
$table->addForeignKeyConstraint( |
1348
|
|
|
$schema->getTable('orocrm_magento_cart_status'), |
1349
|
|
|
['status_name'], |
1350
|
|
|
['name'], |
1351
|
|
|
['onDelete' => 'SET NULL'] |
1352
|
|
|
); |
1353
|
|
|
$table->addForeignKeyConstraint( |
1354
|
|
|
$schema->getTable('orocrm_sales_opportunity'), |
1355
|
|
|
['opportunity_id'], |
1356
|
|
|
['id'], |
1357
|
|
|
['onDelete' => 'SET NULL'] |
1358
|
|
|
); |
1359
|
|
|
$table->addForeignKeyConstraint( |
1360
|
|
|
$schema->getTable('oro_workflow_item'), |
1361
|
|
|
['workflow_item_id'], |
1362
|
|
|
['id'], |
1363
|
|
|
['onDelete' => 'SET NULL'] |
1364
|
|
|
); |
1365
|
|
|
$table->addForeignKeyConstraint( |
1366
|
|
|
$schema->getTable('oro_workflow_step'), |
1367
|
|
|
['workflow_step_id'], |
1368
|
|
|
['id'], |
1369
|
|
|
['onDelete' => 'SET NULL'] |
1370
|
|
|
); |
1371
|
|
|
$table->addForeignKeyConstraint( |
1372
|
|
|
$schema->getTable('oro_user'), |
1373
|
|
|
['user_owner_id'], |
1374
|
|
|
['id'], |
1375
|
|
|
['onDelete' => 'SET NULL'] |
1376
|
|
|
); |
1377
|
|
|
$table->addForeignKeyConstraint( |
1378
|
|
|
$schema->getTable('oro_integration_channel'), |
1379
|
|
|
['channel_id'], |
1380
|
|
|
['id'], |
1381
|
|
|
['onDelete' => 'SET NULL'] |
1382
|
|
|
); |
1383
|
|
|
$table->addForeignKeyConstraint( |
1384
|
|
|
$schema->getTable('orocrm_channel'), |
1385
|
|
|
['data_channel_id'], |
1386
|
|
|
['id'], |
1387
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1388
|
|
|
'FK_96661A80BDC09B73' |
1389
|
|
|
); |
1390
|
|
|
$table->addForeignKeyConstraint( |
1391
|
|
|
$schema->getTable('oro_organization'), |
1392
|
|
|
['organization_id'], |
1393
|
|
|
['id'], |
1394
|
|
|
['onDelete' => 'SET NULL', 'onUpdate' => null], |
1395
|
|
|
'FK_96661A8032C8A3DE' |
1396
|
|
|
); |
1397
|
|
|
} |
1398
|
|
|
|
1399
|
|
|
/** |
1400
|
|
|
* Add orocrm_magento_cart_calls foreign keys. |
1401
|
|
|
* |
1402
|
|
|
* @param Schema $schema |
1403
|
|
|
*/ |
1404
|
|
View Code Duplication |
protected function addOrocrmMagentoCartCallsForeignKeys(Schema $schema) |
|
|
|
|
1405
|
|
|
{ |
1406
|
|
|
$table = $schema->getTable('orocrm_magento_cart_calls'); |
1407
|
|
|
$table->addForeignKeyConstraint( |
1408
|
|
|
$schema->getTable('orocrm_magento_cart'), |
1409
|
|
|
['cart_id'], |
1410
|
|
|
['id'], |
1411
|
|
|
['onDelete' => 'CASCADE'] |
1412
|
|
|
); |
1413
|
|
|
$table->addForeignKeyConstraint( |
1414
|
|
|
$schema->getTable('orocrm_call'), |
1415
|
|
|
['call_id'], |
1416
|
|
|
['id'], |
1417
|
|
|
['onDelete' => 'CASCADE'] |
1418
|
|
|
); |
1419
|
|
|
} |
1420
|
|
|
|
1421
|
|
|
/** |
1422
|
|
|
* Add orocrm_magento_cart_emails foreign keys. |
1423
|
|
|
* |
1424
|
|
|
* @param Schema $schema |
1425
|
|
|
*/ |
1426
|
|
View Code Duplication |
protected function addOrocrmMagentoCartEmailsForeignKeys(Schema $schema) |
|
|
|
|
1427
|
|
|
{ |
1428
|
|
|
$table = $schema->getTable('orocrm_magento_cart_emails'); |
1429
|
|
|
$table->addForeignKeyConstraint( |
1430
|
|
|
$schema->getTable('orocrm_magento_cart'), |
1431
|
|
|
['cart_id'], |
1432
|
|
|
['id'], |
1433
|
|
|
['onDelete' => 'CASCADE'] |
1434
|
|
|
); |
1435
|
|
|
$table->addForeignKeyConstraint( |
1436
|
|
|
$schema->getTable('oro_email'), |
1437
|
|
|
['email_id'], |
1438
|
|
|
['id'], |
1439
|
|
|
['onDelete' => 'CASCADE'] |
1440
|
|
|
); |
1441
|
|
|
} |
1442
|
|
|
|
1443
|
|
|
/** |
1444
|
|
|
* Add orocrm_magento_store foreign keys. |
1445
|
|
|
* |
1446
|
|
|
* @param Schema $schema |
1447
|
|
|
*/ |
1448
|
|
View Code Duplication |
protected function addOrocrmMagentoStoreForeignKeys(Schema $schema) |
|
|
|
|
1449
|
|
|
{ |
1450
|
|
|
$table = $schema->getTable('orocrm_magento_store'); |
1451
|
|
|
$table->addForeignKeyConstraint( |
1452
|
|
|
$schema->getTable('orocrm_magento_website'), |
1453
|
|
|
['website_id'], |
1454
|
|
|
['id'], |
1455
|
|
|
['onDelete' => 'cascade'] |
1456
|
|
|
); |
1457
|
|
|
$table->addForeignKeyConstraint( |
1458
|
|
|
$schema->getTable('oro_integration_channel'), |
1459
|
|
|
['channel_id'], |
1460
|
|
|
['id'], |
1461
|
|
|
['onDelete' => 'SET NULL'] |
1462
|
|
|
); |
1463
|
|
|
} |
1464
|
|
|
|
1465
|
|
|
/** |
1466
|
|
|
* Add orocrm_magento_order_items foreign keys. |
1467
|
|
|
* |
1468
|
|
|
* @param Schema $schema |
1469
|
|
|
*/ |
1470
|
|
View Code Duplication |
protected function addOrocrmMagentoOrderItemsForeignKeys(Schema $schema) |
|
|
|
|
1471
|
|
|
{ |
1472
|
|
|
$table = $schema->getTable('orocrm_magento_order_items'); |
1473
|
|
|
$table->addForeignKeyConstraint( |
1474
|
|
|
$schema->getTable('orocrm_magento_order'), |
1475
|
|
|
['order_id'], |
1476
|
|
|
['id'], |
1477
|
|
|
['onDelete' => 'CASCADE'] |
1478
|
|
|
); |
1479
|
|
|
$table->addForeignKeyConstraint( |
1480
|
|
|
$schema->getTable('oro_integration_channel'), |
1481
|
|
|
['channel_id'], |
1482
|
|
|
['id'], |
1483
|
|
|
['onDelete' => 'SET NULL'] |
1484
|
|
|
); |
1485
|
|
|
$table->addForeignKeyConstraint( |
1486
|
|
|
$schema->getTable('oro_organization'), |
1487
|
|
|
['owner_id'], |
1488
|
|
|
['id'], |
1489
|
|
|
['onDelete' => 'SET NULL'] |
1490
|
|
|
); |
1491
|
|
|
} |
1492
|
|
|
|
1493
|
|
|
/** |
1494
|
|
|
* Add orocrm_magento_newsl_subscr foreign keys. |
1495
|
|
|
* |
1496
|
|
|
* @param Schema $schema |
1497
|
|
|
*/ |
1498
|
|
View Code Duplication |
protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema) |
|
|
|
|
1499
|
|
|
{ |
1500
|
|
|
$table = $schema->getTable('orocrm_magento_newsl_subscr'); |
1501
|
|
|
$table->addForeignKeyConstraint( |
1502
|
|
|
$schema->getTable('oro_organization'), |
1503
|
|
|
['organization_id'], |
1504
|
|
|
['id'], |
1505
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1506
|
|
|
); |
1507
|
|
|
$table->addForeignKeyConstraint( |
1508
|
|
|
$schema->getTable('oro_user'), |
1509
|
|
|
['owner_id'], |
1510
|
|
|
['id'], |
1511
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1512
|
|
|
); |
1513
|
|
|
$table->addForeignKeyConstraint( |
1514
|
|
|
$schema->getTable('orocrm_magento_customer'), |
1515
|
|
|
['customer_id'], |
1516
|
|
|
['id'], |
1517
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1518
|
|
|
); |
1519
|
|
|
$table->addForeignKeyConstraint( |
1520
|
|
|
$schema->getTable('orocrm_magento_store'), |
1521
|
|
|
['store_id'], |
1522
|
|
|
['id'], |
1523
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1524
|
|
|
); |
1525
|
|
|
$table->addForeignKeyConstraint( |
1526
|
|
|
$schema->getTable('oro_integration_channel'), |
1527
|
|
|
['channel_id'], |
1528
|
|
|
['id'], |
1529
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1530
|
|
|
); |
1531
|
|
|
$table->addForeignKeyConstraint( |
1532
|
|
|
$schema->getTable('orocrm_channel'), |
1533
|
|
|
['data_channel_id'], |
1534
|
|
|
['id'], |
1535
|
|
|
['onUpdate' => null, 'onDelete' => 'SET NULL'] |
1536
|
|
|
); |
1537
|
|
|
} |
1538
|
|
|
|
1539
|
|
|
/** |
1540
|
|
|
* Enable activities |
1541
|
|
|
* |
1542
|
|
|
* @param Schema $schema |
1543
|
|
|
*/ |
1544
|
|
|
protected function addActivityAssociations(Schema $schema) |
1545
|
|
|
{ |
1546
|
|
|
$this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_magento_customer'); |
1547
|
|
|
$this->activityExtension->addActivityAssociation($schema, 'orocrm_call', 'orocrm_magento_customer'); |
1548
|
|
|
$this->activityExtension->addActivityAssociation($schema, 'orocrm_task', 'orocrm_magento_customer'); |
1549
|
|
|
$this->activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_magento_customer'); |
1550
|
|
|
|
1551
|
|
|
CreateActivityAssociation::addActivityAssociations($schema, $this->activityExtension); |
1552
|
|
|
OrderActivityAssociation::addActivityAssociations($schema, $this->activityExtension); |
1553
|
|
|
} |
1554
|
|
|
|
1555
|
|
|
/** |
1556
|
|
|
* @param Schema $schema |
1557
|
|
|
*/ |
1558
|
|
|
protected function addIdentifierEventAssociations(Schema $schema) |
1559
|
|
|
{ |
1560
|
|
|
$this->identifierEventExtension->addIdentifierAssociation($schema, 'orocrm_magento_customer'); |
1561
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_cart'); |
1562
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_customer'); |
1563
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_order'); |
1564
|
|
|
$this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_product'); |
1565
|
|
|
} |
1566
|
|
|
} |
1567
|
|
|
|
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.