Completed
Push — 1.9 ( 9955b8...d085a6 )
by
unknown
11:29
created

createOrocrmMagentoStoreTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 14
loc 14
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 12
nc 1
nop 1
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_1';
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->createOrocrmMagentoOrderEmailsTable($schema);
126
        $this->createOrocrmMagentoCustomerGroupTable($schema);
127
        $this->createOrocrmMagentoCustomerTable($schema);
128
        $this->createOrocrmMagentoCartItemTable($schema);
129
        $this->createOrocrmMagentoCustomerAddrTable($schema);
130
        $this->createOrocrmMagentoCustAddrTypeTable($schema);
131
        $this->createOrocrmMagentoOrderAddressTable($schema);
132
        $this->createOrocrmMagentoOrderAddrTypeTable($schema);
133
        $this->createOrocrmMagentoProductTable($schema);
134
        $this->createOrocrmMagentoProdToWebsiteTable($schema);
135
        $this->createOrocrmMagentoWebsiteTable($schema);
136
        $this->createOrocrmMagentoCartTable($schema);
137
       
138
        $this->createOrocrmMagentoCartEmailsTable($schema);
139
        $this->createOrocrmMagentoStoreTable($schema);
140
        $this->createOrocrmMagentoCartStatusTable($schema);
141
        $this->createOrocrmMagentoOrderItemsTable($schema);
142
        $this->createOrocrmMagentoNewslSubscrTable($schema);
143
        $this->updateIntegrationTransportTable($schema);
144
145
        /** Foreign keys generation **/
146
        $this->addOrocrmMagentoCartAddressForeignKeys($schema);
147
        $this->addOrocrmMagentoOrderForeignKeys($schema);
148
        
149
        $this->addOrocrmMagentoOrderEmailsForeignKeys($schema);
150
        $this->addOrocrmMagentoCustomerGroupForeignKeys($schema);
151
        $this->addOrocrmMagentoCustomerForeignKeys($schema);
152
        $this->addOrocrmMagentoCartItemForeignKeys($schema);
153
        $this->addOrocrmMagentoCustomerAddrForeignKeys($schema);
154
        $this->addOrocrmMagentoCustAddrTypeForeignKeys($schema);
155
        $this->addOrocrmMagentoOrderAddressForeignKeys($schema);
156
        $this->addOrocrmMagentoOrderAddrTypeForeignKeys($schema);
157
        $this->addOrocrmMagentoProductForeignKeys($schema);
158
        $this->addOrocrmMagentoProdToWebsiteForeignKeys($schema);
159
        $this->addOrocrmMagentoWebsiteForeignKeys($schema);
160
        $this->addOrocrmMagentoCartForeignKeys($schema);
161
        
162
        $this->addOrocrmMagentoCartEmailsForeignKeys($schema);
163
        $this->addOrocrmMagentoStoreForeignKeys($schema);
164
        $this->addOrocrmMagentoOrderItemsForeignKeys($schema);
165
        $this->addOrocrmMagentoNewslSubscrForeignKeys($schema);
166
167
        $this->addActivityAssociations($schema);
168
        OrderActivityAssociation::addNoteAssociations($schema, $this->noteExtension);
169
        $this->addIdentifierEventAssociations($schema);
170
        InheritanceActivityTargets::addInheritanceTargets($schema, $this->activityListExtension);
171
    }
172
173
    /**
174
     * Update oro_integration_transport table.
175
     *
176
     * @param Schema $schema
177
     * @throws \Doctrine\DBAL\Schema\SchemaException
178
     */
179
    protected function updateIntegrationTransportTable(Schema $schema)
180
    {
181
        IntegrationUpdate::updateOroIntegrationTransportTable($schema);
182
        $table = $schema->getTable('oro_integration_transport');
183
        $table->addColumn('admin_url', 'string', ['notnull' => false, 'length' => 255]);
184
        $table->addColumn('initial_sync_start_date', 'datetime', ['notnull' => false]);
185
        $table->addColumn('extension_version', 'string', ['notnull' => false, 'length' => 255]);
186
        $table->addColumn('magento_version', 'string', ['notnull' => false, 'length' => 255]);
187
        $table->addColumn('guest_customer_sync', 'boolean', ['notnull' => false]);
188
        $table->addColumn('mage_newsl_subscr_synced_to_id', 'integer', ['notnull' => false]);
189
    }
190
191
    /**
192
     * Create orocrm_magento_region table
193
     *
194
     * @param Schema $schema
195
     */
196
    protected function createOrocrmMagentoRegionTable(Schema $schema)
197
    {
198
        $table = $schema->createTable('orocrm_magento_region');
199
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
200
        $table->addColumn('combined_code', 'string', ['length' => 60, 'precision' => 0]);
201
        $table->addColumn('code', 'string', ['length' => 32, 'precision' => 0]);
202
        $table->addColumn('country_code', 'string', ['length' => 255, 'precision' => 0]);
203
        $table->addColumn('region_id', 'integer', ['precision' => 0]);
204
        $table->addColumn('name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
205
        $table->setPrimaryKey(['id']);
206
        $table->addIndex(['region_id'], 'idx_region', []);
207
        $table->addUniqueIndex(['combined_code'], 'unq_code');
208
    }
209
210
    /**
211
     * Create orocrm_magento_cart_address table
212
     *
213
     * @param Schema $schema
214
     */
215
    protected function createOrocrmMagentoCartAddressTable(Schema $schema)
216
    {
217
        $table = $schema->createTable('orocrm_magento_cart_address');
218
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
219
        $table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]);
220
        $table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]);
221
        $table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
222
        $table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
223
        $table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]);
224
        $table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]);
225
        $table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
226
        $table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
227
        $table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
228
        $table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
229
        $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
230
        $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
231
        $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
232
        $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
233
        $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
234
        $table->addColumn('created', 'datetime', ['precision' => 0]);
235
        $table->addColumn('updated', 'datetime', ['precision' => 0]);
236
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
237
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
238
        $table->addIndex(['country_code'], 'IDX_6978F651F026BB7C', []);
239
        $table->addIndex(['region_code'], 'IDX_6978F651AEB327AF', []);
240
        $table->setPrimaryKey(['id']);
241
    }
242
243
    /**
244
     * Create orocrm_magento_order table
245
     *
246
     * @param Schema $schema
247
     */
248
    protected function createOrocrmMagentoOrderTable(Schema $schema)
249
    {
250
        $table = $schema->createTable('orocrm_magento_order');
251
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
252
        $table->addColumn('customer_id', 'integer', ['notnull' => false]);
253
        $table->addColumn('store_id', 'integer', ['notnull' => false]);
254
        $table->addColumn('cart_id', 'integer', ['notnull' => false]);
255
        $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]);
256
        $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]);
257
        $table->addColumn('user_owner_id', 'integer', ['notnull' => false]);
258
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
259
        $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
260
        $table->addColumn('increment_id', 'string', ['length' => 60, 'precision' => 0]);
261
        $table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]);
262
        $table->addColumn('is_guest', 'boolean', ['notnull' => false, 'precision' => 0]);
263
        $table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
264
        $table->addColumn('remote_ip', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
265
        $table->addColumn('store_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
266
        $table->addColumn('total_paid_amount', 'float', ['notnull' => false, 'precision' => 0]);
267
        $table->addColumn(
268
            'total_invoiced_amount',
269
            'money',
270
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
271
        );
272
        $table->addColumn(
273
            'total_refunded_amount',
274
            'money',
275
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
276
        );
277
        $table->addColumn(
278
            'total_canceled_amount',
279
            'money',
280
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
281
        );
282
        $table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]);
283
        $table->addColumn('feedback', 'text', ['notnull' => false, 'precision' => 0]);
284
        $table->addColumn('customer_email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
285
        $table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]);
286
        $table->addColumn('payment_method', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
287
        $table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
288
        $table->addColumn(
289
            'subtotal_amount',
290
            'money',
291
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
292
        );
293
        $table->addColumn(
294
            'shipping_amount',
295
            'money',
296
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
297
        );
298
        $table->addColumn('shipping_method', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
299
        $table->addColumn(
300
            'tax_amount',
301
            'money',
302
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
303
        );
304
        $table->addColumn(
305
            'discount_amount',
306
            'money',
307
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
308
        );
309
        $table->addColumn(
310
            'discount_percent',
311
            'percent',
312
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)']
313
        );
314
        $table->addColumn(
315
            'total_amount',
316
            'money',
317
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
318
        );
319
        $table->addColumn('status', 'string', ['length' => 255, 'precision' => 0]);
320
        $table->addColumn('created_at', 'datetime', ['precision' => 0]);
321
        $table->addColumn('updated_at', 'datetime', ['precision' => 0]);
322
        $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
323
        $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
324
        $table->addColumn('organization_id', 'integer', ['notnull' => false]);
325
        $table->addColumn('coupon_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
326
        $table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
327
        $table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
328
        $table->addIndex(['customer_id'], 'IDX_4D09F3059395C3F3', []);
329
        $table->addIndex(['store_id'], 'IDX_4D09F305B092A811', []);
330
        $table->addIndex(['cart_id'], 'IDX_4D09F3051AD5CDBF', []);
331
        $table->addUniqueIndex(['workflow_item_id'], 'UNIQ_4D09F3051023C4EE');
332
        $table->addIndex(['workflow_step_id'], 'IDX_4D09F30571FE882C', []);
333
        $table->addIndex(['user_owner_id'], 'IDX_4D09F3059EB185F9', []);
334
        $table->addIndex(['channel_id'], 'IDX_4D09F30572F5A1AA', []);
335
        $table->addIndex(['data_channel_id'], 'IDX_4D09F305BDC09B73', []);
336
        $table->addIndex(['organization_id'], 'IDX_4D09F30532C8A3DE', []);
337
        $table->setPrimaryKey(['id']);
338
        $table->addIndex(['created_at'], 'mageorder_created_idx', []);
339
        $table->addUniqueIndex(['increment_id', 'channel_id'], 'unq_increment_id_channel_id');
340
    }
341
342
    
343
344
    /**
345
     * Create orocrm_magento_order_emails table
346
     *
347
     * @param Schema $schema
348
     */
349 View Code Duplication
    protected function createOrocrmMagentoOrderEmailsTable(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
350
    {
351
        $table = $schema->createTable('orocrm_magento_order_emails');
352
        $table->addColumn('order_id', 'integer', []);
353
        $table->addColumn('email_id', 'integer', []);
354
        $table->addIndex(['order_id'], 'IDX_10E2A9508D9F6D38', []);
355
        $table->addIndex(['email_id'], 'IDX_10E2A950A832C1C9', []);
356
        $table->setPrimaryKey(['order_id', 'email_id']);
357
    }
358
359
    /**
360
     * Create orocrm_magento_customer_group table
361
     *
362
     * @param Schema $schema
363
     */
364
    protected function createOrocrmMagentoCustomerGroupTable(Schema $schema)
365
    {
366
        $table = $schema->createTable('orocrm_magento_customer_group');
367
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
368
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
369
        $table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]);
370
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
371
        $table->addIndex(['channel_id'], 'IDX_71E09CA872F5A1AA', []);
372
        $table->setPrimaryKey(['id']);
373
    }
374
375
    /**
376
     * Create orocrm_magento_customer table
377
     *
378
     * @param Schema $schema
379
     */
380
    protected function createOrocrmMagentoCustomerTable(Schema $schema)
381
    {
382
        $table = $schema->createTable('orocrm_magento_customer');
383
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
384
        $table->addColumn('website_id', 'integer', ['notnull' => false]);
385
        $table->addColumn('store_id', 'integer', ['notnull' => false]);
386
        $table->addColumn('customer_group_id', 'integer', ['notnull' => false]);
387
        $table->addColumn('contact_id', 'integer', ['notnull' => false]);
388
        $table->addColumn('account_id', 'integer', ['notnull' => false]);
389
        $table->addColumn('user_owner_id', 'integer', ['notnull' => false]);
390
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
391
        $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
392
        $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
393
        $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
394
        $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
395
        $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
396
        $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
397
        $table->addColumn('gender', 'string', ['notnull' => false, 'length' => 8, 'precision' => 0]);
398
        $table->addColumn('birthday', 'date', ['notnull' => false, 'precision' => 0]);
399
        $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
400
        $table->addColumn('created_at', 'datetime', ['precision' => 0]);
401
        $table->addColumn('updated_at', 'datetime', ['precision' => 0]);
402
        $table->addColumn('is_active', 'boolean', ['precision' => 0]);
403
        $table->addColumn('vat', 'string', ['notnull' => false, 'length' => 255]);
404
        $table->addColumn('lifetime', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']);
405
        $table->addColumn('currency', 'string', ['notnull' => false, 'length' => 10, 'precision' => 0]);
406
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
407
        $table->addColumn('organization_id', 'integer', ['notnull' => false]);
408
        $table->addColumn('rfm_recency', 'integer', ['notnull' => false]);
409
        $table->addColumn('rfm_frequency', 'integer', ['notnull' => false]);
410
        $table->addColumn('rfm_monetary', 'integer', ['notnull' => false]);
411
        $table->addColumn('sync_state', 'integer', ['notnull' => false]);
412
        $table->addColumn('password', 'string', ['notnull' => false, 'length' => 32]);
413
        $table->addColumn('created_in', 'string', ['notnull' => false, 'length' => 255]);
414
        $table->addColumn('is_confirmed', 'boolean', ['notnull' => false]);
415
        $table->addColumn('is_guest', 'boolean', ['notnull' => true, 'default' => false]);
416
        $table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
417
        $table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
418
        $table->addIndex(['website_id'], 'IDX_2A61EE7D18F45C82', []);
419
        $table->addIndex(['store_id'], 'IDX_2A61EE7DB092A811', []);
420
        $table->addIndex(['customer_group_id'], 'IDX_2A61EE7DD2919A68', []);
421
        $table->addIndex(['contact_id'], 'IDX_2A61EE7DE7A1254A', []);
422
        $table->addIndex(['account_id'], 'IDX_2A61EE7D9B6B5FBA', []);
423
        $table->addIndex(['user_owner_id'], 'IDX_2A61EE7D9EB185F9', []);
424
        $table->addIndex(['channel_id'], 'IDX_2A61EE7D72F5A1AA', []);
425
        $table->addIndex(['data_channel_id'], 'IDX_2A61EE7DBDC09B73', []);
426
        $table->addIndex(['organization_id'], 'IDX_2A61EE7D32C8A3DE', []);
427
        $table->setPrimaryKey(['id']);
428
        $table->addIndex(['first_name', 'last_name'], 'magecustomer_name_idx', []);
429
        $table->addIndex(['last_name', 'first_name'], 'magecustomer_rev_name_idx', []);
430
        $table->addIndex(['email'], 'magecustomer_email_guest_idx', []);
431
        $table->addUniqueIndex(['origin_id', 'channel_id'], 'magecustomer_oid_cid_unq');
432
    }
433
434
    /**
435
     * Create orocrm_magento_cart_item table
436
     *
437
     * @param Schema $schema
438
     */
439
    protected function createOrocrmMagentoCartItemTable(Schema $schema)
440
    {
441
        $table = $schema->createTable('orocrm_magento_cart_item');
442
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
443
        $table->addColumn('cart_id', 'integer', ['notnull' => false]);
444
        $table->addColumn('product_id', 'integer', ['precision' => 0, 'unsigned' => true]);
445
        $table->addColumn('parent_item_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
446
        $table->addColumn('free_shipping', 'string', ['length' => 255, 'precision' => 0]);
447
        $table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
448
        $table->addColumn('tax_class_id', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
449
        $table->addColumn('description', 'text', ['notnull' => false, 'precision' => 0]);
450
        $table->addColumn('is_virtual', 'boolean', ['precision' => 0]);
451
        $table->addColumn(
452
            'custom_price',
453
            'money',
454
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
455
        );
456
        $table->addColumn(
457
            'price_incl_tax',
458
            'money',
459
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
460
        );
461
        $table->addColumn('row_total', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']);
462
        $table->addColumn('tax_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']);
463
        $table->addColumn('product_type', 'string', ['length' => 255, 'precision' => 0]);
464
        $table->addColumn('product_image_url', 'text', ['notnull' => false]);
465
        $table->addColumn('product_url', 'text', ['notnull' => false]);
466
        $table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0, 'notnull' => false]);
467
        $table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]);
468
        $table->addColumn('qty', 'float', ['precision' => 0]);
469
        $table->addColumn('price', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']);
470
        $table->addColumn('discount_amount', 'money', ['precision' => 0, 'comment' => '(DC2Type:money)']);
471
        $table->addColumn('tax_percent', 'percent', ['precision' => 0, 'comment' => '(DC2Type:percent)']);
472
        $table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]);
473
        $table->addColumn('createdAt', 'datetime', ['precision' => 0]);
474
        $table->addColumn('updatedAt', 'datetime', ['precision' => 0]);
475
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
476
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
477
        $table->addColumn('is_removed', 'boolean', ['notnull' => true, 'default' => false]);
478
        $table->addColumn('owner_id', 'integer', ['notnull' => false]);
479
        $table->addIndex(['cart_id'], 'IDX_A73DC8621AD5CDBF', []);
480
        $table->addIndex(['owner_id'], 'IDX_A73DC8627E3C61F9', []);
481
        $table->setPrimaryKey(['id']);
482
        $table->addIndex(['origin_id'], 'magecartitem_origin_idx', []);
483
        $table->addIndex(['sku'], 'magecartitem_sku_idx', []);
484
    }
485
486
    /**
487
     * Create orocrm_magento_customer_addr table
488
     *
489
     * @param Schema $schema
490
     */
491
    protected function createOrocrmMagentoCustomerAddrTable(Schema $schema)
492
    {
493
        $table = $schema->createTable('orocrm_magento_customer_addr');
494
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
495
        $table->addColumn('owner_id', 'integer', ['notnull' => false]);
496
        $table->addColumn('related_contact_address_id', 'integer', ['notnull' => false]);
497
        $table->addColumn('related_contact_phone_id', 'integer', ['notnull' => false]);
498
        $table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]);
499
        $table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]);
500
        $table->addColumn('label', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
501
        $table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]);
502
        $table->addColumn('street2', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]);
503
        $table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
504
        $table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
505
        $table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
506
        $table->addColumn('name_prefix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
507
        $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
508
        $table->addColumn('middle_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
509
        $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
510
        $table->addColumn('name_suffix', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
511
        $table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
512
        $table->addColumn('is_primary', 'boolean', ['notnull' => false, 'precision' => 0]);
513
        $table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
514
        $table->addColumn('created', 'datetime', ['precision' => 0]);
515
        $table->addColumn('updated', 'datetime', ['precision' => 0]);
516
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
517
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
518
        $table->addColumn('sync_state', 'integer', ['notnull' => false]);
519
        $table->addIndex(['owner_id'], 'IDX_1E239D647E3C61F9', []);
520
        $table->addUniqueIndex(['related_contact_address_id'], 'UNIQ_1E239D648137CB7B');
521
        $table->addUniqueIndex(['related_contact_phone_id'], 'UNIQ_1E239D64E3694F65');
522
        $table->addIndex(['country_code'], 'IDX_1E239D64F026BB7C', []);
523
        $table->addIndex(['region_code'], 'IDX_1E239D64AEB327AF', []);
524
        $table->setPrimaryKey(['id']);
525
    }
526
527
    /**
528
     * Create orocrm_magento_cust_addr_type table
529
     *
530
     * @param Schema $schema
531
     */
532 View Code Duplication
    protected function createOrocrmMagentoCustAddrTypeTable(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
533
    {
534
        $table = $schema->createTable('orocrm_magento_cust_addr_type');
535
        $table->addColumn('customer_address_id', 'integer', []);
536
        $table->addColumn('type_name', 'string', ['length' => 16]);
537
        $table->addIndex(['customer_address_id'], 'IDX_308A31F187EABF7', []);
538
        $table->addIndex(['type_name'], 'IDX_308A31F1892CBB0E', []);
539
        $table->setPrimaryKey(['customer_address_id', 'type_name']);
540
    }
541
542
    /**
543
     * Create orocrm_magento_order_address table
544
     *
545
     * @param Schema $schema
546
     */
547
    protected function createOrocrmMagentoOrderAddressTable(Schema $schema)
548
    {
549
        $table = $schema->createTable('orocrm_magento_order_address');
550
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
551
        $table->addColumn('owner_id', 'integer', ['notnull' => false]);
552
        $table->addColumn('country_code', 'string', ['notnull' => false, 'length' => 2]);
553
        $table->addColumn('region_code', 'string', ['notnull' => false, 'length' => 16]);
554
        $table->addColumn('fax', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
555
        $table->addColumn('phone', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
556
        $table->addColumn('street', 'string', ['notnull' => false, 'length' => 500, 'precision' => 0]);
557
        $table->addColumn('city', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
558
        $table->addColumn('postal_code', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
559
        $table->addColumn('organization', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
560
        $table->addColumn('region_text', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
561
        $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
562
        $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
563
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
564
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
565
        $table->addIndex(['owner_id'], 'IDX_E31C6DEC7E3C61F9', []);
566
        $table->addIndex(['country_code'], 'IDX_E31C6DECF026BB7C', []);
567
        $table->addIndex(['region_code'], 'IDX_E31C6DECAEB327AF', []);
568
        $table->setPrimaryKey(['id']);
569
    }
570
571
    /**
572
     * Create orocrm_magento_order_addr_type table
573
     *
574
     * @param Schema $schema
575
     */
576 View Code Duplication
    protected function createOrocrmMagentoOrderAddrTypeTable(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
577
    {
578
        $table = $schema->createTable('orocrm_magento_order_addr_type');
579
        $table->addColumn('order_address_id', 'integer', []);
580
        $table->addColumn('type_name', 'string', ['length' => 16]);
581
        $table->addIndex(['order_address_id'], 'IDX_E927A18F466D5220', []);
582
        $table->addIndex(['type_name'], 'IDX_E927A18F892CBB0E', []);
583
        $table->setPrimaryKey(['order_address_id', 'type_name']);
584
    }
585
586
    /**
587
     * Create orocrm_magento_product table
588
     *
589
     * @param Schema $schema
590
     */
591
    protected function createOrocrmMagentoProductTable(Schema $schema)
592
    {
593
        $table = $schema->createTable('orocrm_magento_product');
594
        $table->addColumn('id', 'integer', ['autoincrement' => true]);
595
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
596
        $table->addColumn('name', 'string', ['length' => 255]);
597
        $table->addColumn('sku', 'string', ['length' => 255, 'notnull' => false]);
598
        $table->addColumn('type', 'string', ['length' => 255]);
599
        $table->addColumn(
600
            'special_price',
601
            'money',
602
            ['notnull' => false]
603
        );
604
        $table->addColumn('price', 'money', ['notnull' => false]);
605
        $table->addColumn('created_at', 'datetime');
606
        $table->addColumn('updated_at', 'datetime');
607
        $table->addColumn('origin_id', 'integer', ['unsigned' => true]);
608
        $table->addColumn('cost', 'money', ['notnull' => false]);
609
        $table->addIndex(['channel_id'], 'IDX_5A17298272F5A1AA', []);
610
        $table->setPrimaryKey(['id']);
611
    }
612
613
    /**
614
     * Create orocrm_magento_prod_to_website table
615
     *
616
     * @param Schema $schema
617
     */
618 View Code Duplication
    protected function createOrocrmMagentoProdToWebsiteTable(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
619
    {
620
        $table = $schema->createTable('orocrm_magento_prod_to_website');
621
        $table->addColumn('product_id', 'integer', []);
622
        $table->addColumn('website_id', 'integer', []);
623
        $table->addIndex(['product_id'], 'IDX_9BB836554584665A', []);
624
        $table->addIndex(['website_id'], 'IDX_9BB8365518F45C82', []);
625
        $table->setPrimaryKey(['product_id', 'website_id']);
626
    }
627
628
    /**
629
     * Create orocrm_magento_website table
630
     *
631
     * @param Schema $schema
632
     */
633
    protected function createOrocrmMagentoWebsiteTable(Schema $schema)
634
    {
635
        $table = $schema->createTable('orocrm_magento_website');
636
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
637
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
638
        $table->addColumn('website_code', 'string', ['length' => 32, 'precision' => 0]);
639
        $table->addColumn('website_name', 'string', ['length' => 255, 'precision' => 0]);
640
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
641
        $table->addColumn('sort_order', 'integer', ['notnull' => false]);
642
        $table->addColumn('is_default', 'boolean', ['notnull' => false]);
643
        $table->addColumn('default_group_id', 'integer', ['notnull' => false]);
644
        $table->addIndex(['channel_id'], 'IDX_CE3270C872F5A1AA', []);
645
        $table->setPrimaryKey(['id']);
646
        $table->addIndex(['website_name'], 'orocrm_magento_website_name_idx', []);
647
        $table->addUniqueIndex(['website_code', 'origin_id', 'channel_id'], 'unq_site_idx');
648
    }
649
650
    /**
651
     * Create orocrm_magento_cart table
652
     *
653
     * @param Schema $schema
654
     */
655
    protected function createOrocrmMagentoCartTable(Schema $schema)
656
    {
657
        $table = $schema->createTable('orocrm_magento_cart');
658
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
659
        $table->addColumn('customer_id', 'integer', ['notnull' => false]);
660
        $table->addColumn('store_id', 'integer', ['notnull' => false]);
661
        $table->addColumn('shipping_address_id', 'integer', ['notnull' => false]);
662
        $table->addColumn('billing_address_id', 'integer', ['notnull' => false]);
663
        $table->addColumn('status_name', 'string', ['notnull' => false, 'length' => 32]);
664
        $table->addColumn('opportunity_id', 'integer', ['notnull' => false]);
665
        $table->addColumn('workflow_item_id', 'integer', ['notnull' => false]);
666
        $table->addColumn('workflow_step_id', 'integer', ['notnull' => false]);
667
        $table->addColumn('user_owner_id', 'integer', ['notnull' => false]);
668
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
669
        $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
670
        $table->addColumn('items_qty', 'float', ['precision' => 0]);
671
        $table->addColumn('items_count', 'integer', ['precision' => 0, 'unsigned' => true]);
672
        $table->addColumn('base_currency_code', 'string', ['length' => 32, 'precision' => 0]);
673
        $table->addColumn('store_currency_code', 'string', ['length' => 32, 'precision' => 0]);
674
        $table->addColumn('quote_currency_code', 'string', ['length' => 32, 'precision' => 0]);
675
        $table->addColumn('store_to_base_rate', 'float', ['precision' => 0]);
676
        $table->addColumn('store_to_quote_rate', 'float', ['notnull' => false, 'precision' => 0]);
677
        $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
678
        $table->addColumn('gift_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
679
        $table->addColumn('is_guest', 'boolean', ['precision' => 0]);
680
        $table->addColumn('payment_details', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
681
        $table->addColumn('notes', 'text', ['notnull' => false, 'precision' => 0]);
682
        $table->addColumn('status_message', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
683
        $table->addColumn('sub_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']);
684
        $table->addColumn(
685
            'grand_total',
686
            'money',
687
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
688
        );
689
        $table->addColumn(
690
            'tax_amount',
691
            'money',
692
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
693
        );
694
        $table->addColumn('createdAt', 'datetime', ['precision' => 0]);
695
        $table->addColumn('updatedAt', 'datetime', ['precision' => 0]);
696
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
697
        $table->addColumn('first_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
698
        $table->addColumn('last_name', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
699
        $table->addColumn('organization_id', 'integer', ['notnull' => false]);
700
        $table->addColumn('imported_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
701
        $table->addColumn('synced_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
702
        $table->addIndex(['customer_id'], 'IDX_96661A809395C3F3', []);
703
        $table->addIndex(['store_id'], 'IDX_96661A80B092A811', []);
704
        $table->addIndex(['shipping_address_id'], 'IDX_96661A804D4CFF2B', []);
705
        $table->addIndex(['billing_address_id'], 'IDX_96661A8079D0C0E4', []);
706
        $table->addIndex(['status_name'], 'IDX_96661A806625D392', []);
707
        $table->addIndex(['opportunity_id'], 'IDX_96661A809A34590F', []);
708
        $table->addUniqueIndex(['workflow_item_id'], 'UNIQ_96661A801023C4EE');
709
        $table->addIndex(['workflow_step_id'], 'IDX_96661A8071FE882C', []);
710
        $table->addIndex(['user_owner_id'], 'IDX_96661A809EB185F9', []);
711
        $table->addIndex(['channel_id'], 'IDX_96661A8072F5A1AA', []);
712
        $table->addIndex(['data_channel_id'], 'IDX_96661A80BDC09B73', []);
713
        $table->addIndex(['organization_id'], 'IDX_96661A8032C8A3DE', []);
714
        $table->setPrimaryKey(['id']);
715
        $table->addIndex(['origin_id'], 'magecart_origin_idx', []);
716
        $table->addIndex(['updatedAt'], 'magecart_updated_idx', []);
717
        $table->addUniqueIndex(['origin_id', 'channel_id'], 'unq_cart_origin_id_channel_id');
718
    }
719
720
    /**
721
     * Create orocrm_magento_cart_emails table
722
     *
723
     * @param Schema $schema
724
     */
725 View Code Duplication
    protected function createOrocrmMagentoCartEmailsTable(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
726
    {
727
        $table = $schema->createTable('orocrm_magento_cart_emails');
728
        $table->addColumn('cart_id', 'integer', []);
729
        $table->addColumn('email_id', 'integer', []);
730
        $table->addIndex(['cart_id'], 'IDX_11B0F84B1AD5CDBF', []);
731
        $table->addIndex(['email_id'], 'IDX_11B0F84BA832C1C9', []);
732
        $table->setPrimaryKey(['cart_id', 'email_id']);
733
    }
734
735
    /**
736
     * Create orocrm_magento_store table
737
     *
738
     * @param Schema $schema
739
     */
740 View Code Duplication
    protected function createOrocrmMagentoStoreTable(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
741
    {
742
        $table = $schema->createTable('orocrm_magento_store');
743
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
744
        $table->addColumn('website_id', 'integer', []);
745
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
746
        $table->addColumn('store_code', 'string', ['length' => 32, 'precision' => 0]);
747
        $table->addColumn('store_name', 'string', ['length' => 255, 'precision' => 0]);
748
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
749
        $table->addIndex(['website_id'], 'IDX_477738EA18F45C82', []);
750
        $table->addIndex(['channel_id'], 'IDX_477738EA72F5A1AA', []);
751
        $table->setPrimaryKey(['id']);
752
        $table->addUniqueIndex(['store_code', 'channel_id'], 'unq_code_channel_id');
753
    }
754
755
    /**
756
     * Create orocrm_magento_cart_status table
757
     *
758
     * @param Schema $schema
759
     */
760
    protected function createOrocrmMagentoCartStatusTable(Schema $schema)
761
    {
762
        $table = $schema->createTable('orocrm_magento_cart_status');
763
        $table->addColumn('name', 'string', ['length' => 32, 'precision' => 0]);
764
        $table->addColumn('label', 'string', ['length' => 255, 'precision' => 0]);
765
        $table->addUniqueIndex(['label'], 'UNIQ_26317505EA750E8');
766
        $table->setPrimaryKey(['name']);
767
    }
768
769
    /**
770
     * Create orocrm_magento_order_items table
771
     *
772
     * @param Schema $schema
773
     */
774
    protected function createOrocrmMagentoOrderItemsTable(Schema $schema)
775
    {
776
        $table = $schema->createTable('orocrm_magento_order_items');
777
        $table->addColumn('id', 'integer', ['precision' => 0, 'autoincrement' => true]);
778
        $table->addColumn('order_id', 'integer', ['notnull' => false]);
779
        $table->addColumn('product_type', 'string', ['notnull' => false, 'length' => 255, 'precision' => 0]);
780
        $table->addColumn('product_options', 'text', ['notnull' => false, 'precision' => 0]);
781
        $table->addColumn('is_virtual', 'boolean', ['notnull' => false, 'precision' => 0]);
782
        $table->addColumn(
783
            'original_price',
784
            'money',
785
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
786
        );
787
        $table->addColumn(
788
            'discount_percent',
789
            'percent',
790
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)']
791
        );
792
        $table->addColumn('name', 'string', ['length' => 255, 'precision' => 0]);
793
        $table->addColumn('sku', 'string', ['length' => 255, 'precision' => 0, 'notnull' => false]);
794
        $table->addColumn('qty', 'float', ['precision' => 0]);
795
        $table->addColumn('price', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']);
796
        $table->addColumn('weight', 'float', ['notnull' => false, 'precision' => 0]);
797
        $table->addColumn(
798
            'tax_percent',
799
            'percent',
800
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:percent)']
801
        );
802
        $table->addColumn(
803
            'tax_amount',
804
            'money',
805
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
806
        );
807
        $table->addColumn(
808
            'discount_amount',
809
            'money',
810
            ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']
811
        );
812
        $table->addColumn('row_total', 'money', ['notnull' => false, 'precision' => 0, 'comment' => '(DC2Type:money)']);
813
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
814
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
815
        $table->addColumn('owner_id', 'integer', ['notnull' => false]);
816
        $table->addIndex(['order_id'], 'IDX_3135EFF68D9F6D38', []);
817
        $table->addIndex(['owner_id'], 'IDX_3135EFF67E3C61F9', []);
818
        $table->setPrimaryKey(['id']);
819
    }
820
821
    /**
822
     * Create orocrm_magento_newsl_subscr table
823
     *
824
     * @param Schema $schema
825
     */
826
    protected function createOrocrmMagentoNewslSubscrTable(Schema $schema)
827
    {
828
        $table = $schema->createTable('orocrm_magento_newsl_subscr');
829
        $table->addColumn('id', 'integer', ['autoincrement' => true]);
830
        $table->addColumn('organization_id', 'integer', ['notnull' => false]);
831
        $table->addColumn('owner_id', 'integer', ['notnull' => false]);
832
        $table->addColumn('customer_id', 'integer', ['notnull' => false]);
833
        $table->addColumn('store_id', 'integer', ['notnull' => false]);
834
        $table->addColumn('channel_id', 'integer', ['notnull' => false]);
835
        $table->addColumn('data_channel_id', 'integer', ['notnull' => false]);
836
        $table->addColumn('email', 'string', ['notnull' => false, 'length' => 255]);
837
        $table->addColumn('change_status_at', 'datetime', ['notnull' => false, 'comment' => '(DC2Type:datetime)']);
838
        $table->addColumn('created_at', 'datetime', ['comment' => '(DC2Type:datetime)']);
839
        $table->addColumn('updated_at', 'datetime', ['comment' => '(DC2Type:datetime)']);
840
        $table->addColumn('origin_id', 'integer', ['notnull' => false, 'precision' => 0, 'unsigned' => true]);
841
        $table->addColumn('confirm_code', 'string', ['notnull' => false, 'length' => 32]);
842
        $table->setPrimaryKey(['id']);
843
844
        $this->extendExtension->addEnumField(
845
            $schema,
846
            $table,
847
            'status',
848
            'mage_subscr_status',
849
            false,
850
            false,
851
            [
852
                'extend' => ['owner' => ExtendScope::OWNER_CUSTOM]
853
            ]
854
        );
855
    }
856
857
    /**
858
     * Add orocrm_magento_cart_address foreign keys.
859
     *
860
     * @param Schema $schema
861
     */
862
    protected function addOrocrmMagentoCartAddressForeignKeys(Schema $schema)
863
    {
864
        $table = $schema->getTable('orocrm_magento_cart_address');
865
        $table->addForeignKeyConstraint(
866
            $schema->getTable('oro_dictionary_country'),
867
            ['country_code'],
868
            ['iso2_code'],
869
            []
870
        );
871
        $table->addForeignKeyConstraint(
872
            $schema->getTable('oro_dictionary_region'),
873
            ['region_code'],
874
            ['combined_code'],
875
            []
876
        );
877
        $table->addForeignKeyConstraint(
878
            $schema->getTable('oro_integration_channel'),
879
            ['channel_id'],
880
            ['id'],
881
            ['onDelete' => 'SET NULL']
882
        );
883
    }
884
885
    /**
886
     * Add orocrm_magento_order foreign keys.
887
     *
888
     * @param Schema $schema
889
     */
890 View Code Duplication
    protected function addOrocrmMagentoOrderForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
891
    {
892
        $table = $schema->getTable('orocrm_magento_order');
893
        $table->addForeignKeyConstraint(
894
            $schema->getTable('orocrm_magento_customer'),
895
            ['customer_id'],
896
            ['id'],
897
            ['onDelete' => 'SET NULL']
898
        );
899
        $table->addForeignKeyConstraint(
900
            $schema->getTable('orocrm_magento_store'),
901
            ['store_id'],
902
            ['id'],
903
            ['onDelete' => 'SET NULL']
904
        );
905
        $table->addForeignKeyConstraint(
906
            $schema->getTable('orocrm_magento_cart'),
907
            ['cart_id'],
908
            ['id'],
909
            []
910
        );
911
        $table->addForeignKeyConstraint(
912
            $schema->getTable('oro_workflow_item'),
913
            ['workflow_item_id'],
914
            ['id'],
915
            ['onDelete' => 'SET NULL']
916
        );
917
        $table->addForeignKeyConstraint(
918
            $schema->getTable('oro_workflow_step'),
919
            ['workflow_step_id'],
920
            ['id'],
921
            ['onDelete' => 'SET NULL']
922
        );
923
        $table->addForeignKeyConstraint(
924
            $schema->getTable('oro_user'),
925
            ['user_owner_id'],
926
            ['id'],
927
            ['onDelete' => 'SET NULL']
928
        );
929
        $table->addForeignKeyConstraint(
930
            $schema->getTable('oro_integration_channel'),
931
            ['channel_id'],
932
            ['id'],
933
            ['onDelete' => 'SET NULL']
934
        );
935
        $table->addForeignKeyConstraint(
936
            $schema->getTable('orocrm_channel'),
937
            ['data_channel_id'],
938
            ['id'],
939
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
940
            'FK_4D09F305BDC09B73'
941
        );
942
        $table->addForeignKeyConstraint(
943
            $schema->getTable('oro_organization'),
944
            ['organization_id'],
945
            ['id'],
946
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
947
            'FK_4D09F30532C8A3DE'
948
        );
949
    }
950
951
    /**
952
     * Add orocrm_magento_order_emails foreign keys.
953
     *
954
     * @param Schema $schema
955
     */
956 View Code Duplication
    protected function addOrocrmMagentoOrderEmailsForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
957
    {
958
        $table = $schema->getTable('orocrm_magento_order_emails');
959
        $table->addForeignKeyConstraint(
960
            $schema->getTable('orocrm_magento_order'),
961
            ['order_id'],
962
            ['id'],
963
            ['onDelete' => 'CASCADE']
964
        );
965
        $table->addForeignKeyConstraint(
966
            $schema->getTable('oro_email'),
967
            ['email_id'],
968
            ['id'],
969
            ['onDelete' => 'CASCADE']
970
        );
971
    }
972
973
    /**
974
     * Add orocrm_magento_customer_group foreign keys.
975
     *
976
     * @param Schema $schema
977
     */
978 View Code Duplication
    protected function addOrocrmMagentoCustomerGroupForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
979
    {
980
        $table = $schema->getTable('orocrm_magento_customer_group');
981
        $table->addForeignKeyConstraint(
982
            $schema->getTable('oro_integration_channel'),
983
            ['channel_id'],
984
            ['id'],
985
            ['onDelete' => 'SET NULL']
986
        );
987
    }
988
989
    /**
990
     * Add orocrm_magento_customer foreign keys.
991
     *
992
     * @param Schema $schema
993
     */
994 View Code Duplication
    protected function addOrocrmMagentoCustomerForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
995
    {
996
        $table = $schema->getTable('orocrm_magento_customer');
997
        $table->addForeignKeyConstraint(
998
            $schema->getTable('orocrm_magento_website'),
999
            ['website_id'],
1000
            ['id'],
1001
            ['onDelete' => 'SET NULL']
1002
        );
1003
        $table->addForeignKeyConstraint(
1004
            $schema->getTable('orocrm_magento_store'),
1005
            ['store_id'],
1006
            ['id'],
1007
            ['onDelete' => 'SET NULL']
1008
        );
1009
        $table->addForeignKeyConstraint(
1010
            $schema->getTable('orocrm_magento_customer_group'),
1011
            ['customer_group_id'],
1012
            ['id'],
1013
            ['onDelete' => 'SET NULL']
1014
        );
1015
        $table->addForeignKeyConstraint(
1016
            $schema->getTable('orocrm_contact'),
1017
            ['contact_id'],
1018
            ['id'],
1019
            ['onDelete' => 'SET NULL']
1020
        );
1021
        $table->addForeignKeyConstraint(
1022
            $schema->getTable('orocrm_account'),
1023
            ['account_id'],
1024
            ['id'],
1025
            ['onDelete' => 'SET NULL']
1026
        );
1027
        $table->addForeignKeyConstraint(
1028
            $schema->getTable('oro_user'),
1029
            ['user_owner_id'],
1030
            ['id'],
1031
            ['onDelete' => 'SET NULL']
1032
        );
1033
        $table->addForeignKeyConstraint(
1034
            $schema->getTable('oro_integration_channel'),
1035
            ['channel_id'],
1036
            ['id'],
1037
            ['onDelete' => 'SET NULL']
1038
        );
1039
        $table->addForeignKeyConstraint(
1040
            $schema->getTable('orocrm_channel'),
1041
            ['data_channel_id'],
1042
            ['id'],
1043
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
1044
            'FK_2A61EE7DBDC09B73'
1045
        );
1046
        $table->addForeignKeyConstraint(
1047
            $schema->getTable('oro_organization'),
1048
            ['organization_id'],
1049
            ['id'],
1050
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
1051
            'FK_2A61EE7D32C8A3DE'
1052
        );
1053
    }
1054
1055
    /**
1056
     * Add orocrm_magento_cart_item foreign keys.
1057
     *
1058
     * @param Schema $schema
1059
     */
1060 View Code Duplication
    protected function addOrocrmMagentoCartItemForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1061
    {
1062
        $table = $schema->getTable('orocrm_magento_cart_item');
1063
        $table->addForeignKeyConstraint(
1064
            $schema->getTable('orocrm_magento_cart'),
1065
            ['cart_id'],
1066
            ['id'],
1067
            ['onDelete' => 'CASCADE']
1068
        );
1069
        $table->addForeignKeyConstraint(
1070
            $schema->getTable('oro_integration_channel'),
1071
            ['channel_id'],
1072
            ['id'],
1073
            ['onDelete' => 'SET NULL']
1074
        );
1075
        $table->addForeignKeyConstraint(
1076
            $schema->getTable('oro_organization'),
1077
            ['owner_id'],
1078
            ['id'],
1079
            ['onDelete' => 'SET NULL']
1080
        );
1081
    }
1082
1083
    /**
1084
     * Add orocrm_magento_customer_addr foreign keys.
1085
     *
1086
     * @param Schema $schema
1087
     */
1088
    protected function addOrocrmMagentoCustomerAddrForeignKeys(Schema $schema)
1089
    {
1090
        $table = $schema->getTable('orocrm_magento_customer_addr');
1091
        $table->addForeignKeyConstraint(
1092
            $schema->getTable('orocrm_magento_customer'),
1093
            ['owner_id'],
1094
            ['id'],
1095
            ['onDelete' => 'CASCADE']
1096
        );
1097
        $table->addForeignKeyConstraint(
1098
            $schema->getTable('orocrm_contact_address'),
1099
            ['related_contact_address_id'],
1100
            ['id'],
1101
            ['onDelete' => 'SET NULL']
1102
        );
1103
        $table->addForeignKeyConstraint(
1104
            $schema->getTable('orocrm_contact_phone'),
1105
            ['related_contact_phone_id'],
1106
            ['id'],
1107
            ['onDelete' => 'SET NULL']
1108
        );
1109
        $table->addForeignKeyConstraint(
1110
            $schema->getTable('oro_dictionary_country'),
1111
            ['country_code'],
1112
            ['iso2_code'],
1113
            []
1114
        );
1115
        $table->addForeignKeyConstraint(
1116
            $schema->getTable('oro_dictionary_region'),
1117
            ['region_code'],
1118
            ['combined_code'],
1119
            []
1120
        );
1121
        $table->addForeignKeyConstraint(
1122
            $schema->getTable('oro_integration_channel'),
1123
            ['channel_id'],
1124
            ['id'],
1125
            ['onDelete' => 'SET NULL']
1126
        );
1127
    }
1128
1129
    /**
1130
     * Add orocrm_magento_cust_addr_type foreign keys.
1131
     *
1132
     * @param Schema $schema
1133
     */
1134 View Code Duplication
    protected function addOrocrmMagentoCustAddrTypeForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1135
    {
1136
        $table = $schema->getTable('orocrm_magento_cust_addr_type');
1137
        $table->addForeignKeyConstraint(
1138
            $schema->getTable('orocrm_magento_customer_addr'),
1139
            ['customer_address_id'],
1140
            ['id'],
1141
            ['onDelete' => 'CASCADE'],
1142
            'FK_308A31F187EABF7'
1143
        );
1144
        $table->addForeignKeyConstraint(
1145
            $schema->getTable('oro_address_type'),
1146
            ['type_name'],
1147
            ['name'],
1148
            []
1149
        );
1150
    }
1151
1152
    /**
1153
     * Add orocrm_magento_order_address foreign keys.
1154
     *
1155
     * @param Schema $schema
1156
     */
1157
    protected function addOrocrmMagentoOrderAddressForeignKeys(Schema $schema)
1158
    {
1159
        $table = $schema->getTable('orocrm_magento_order_address');
1160
        $table->addForeignKeyConstraint(
1161
            $schema->getTable('orocrm_magento_order'),
1162
            ['owner_id'],
1163
            ['id'],
1164
            ['onDelete' => 'CASCADE']
1165
        );
1166
        $table->addForeignKeyConstraint(
1167
            $schema->getTable('oro_dictionary_country'),
1168
            ['country_code'],
1169
            ['iso2_code'],
1170
            []
1171
        );
1172
        $table->addForeignKeyConstraint(
1173
            $schema->getTable('oro_dictionary_region'),
1174
            ['region_code'],
1175
            ['combined_code'],
1176
            []
1177
        );
1178
        $table->addForeignKeyConstraint(
1179
            $schema->getTable('oro_integration_channel'),
1180
            ['channel_id'],
1181
            ['id'],
1182
            ['onDelete' => 'SET NULL']
1183
        );
1184
    }
1185
1186
    /**
1187
     * Add orocrm_magento_order_addr_type foreign keys.
1188
     *
1189
     * @param Schema $schema
1190
     */
1191 View Code Duplication
    protected function addOrocrmMagentoOrderAddrTypeForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1192
    {
1193
        $table = $schema->getTable('orocrm_magento_order_addr_type');
1194
        $table->addForeignKeyConstraint(
1195
            $schema->getTable('orocrm_magento_order_address'),
1196
            ['order_address_id'],
1197
            ['id'],
1198
            ['onDelete' => 'CASCADE'],
1199
            'FK_E927A18F466D5220'
1200
        );
1201
        $table->addForeignKeyConstraint(
1202
            $schema->getTable('oro_address_type'),
1203
            ['type_name'],
1204
            ['name'],
1205
            []
1206
        );
1207
    }
1208
1209
    /**
1210
     * Add orocrm_magento_product foreign keys.
1211
     *
1212
     * @param Schema $schema
1213
     */
1214 View Code Duplication
    protected function addOrocrmMagentoProductForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1215
    {
1216
        $table = $schema->getTable('orocrm_magento_product');
1217
        $table->addForeignKeyConstraint(
1218
            $schema->getTable('oro_integration_channel'),
1219
            ['channel_id'],
1220
            ['id'],
1221
            ['onDelete' => 'SET NULL']
1222
        );
1223
    }
1224
1225
    /**
1226
     * Add orocrm_magento_prod_to_website foreign keys.
1227
     *
1228
     * @param Schema $schema
1229
     */
1230 View Code Duplication
    protected function addOrocrmMagentoProdToWebsiteForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1231
    {
1232
        $table = $schema->getTable('orocrm_magento_prod_to_website');
1233
        $table->addForeignKeyConstraint(
1234
            $schema->getTable('orocrm_magento_product'),
1235
            ['product_id'],
1236
            ['id'],
1237
            ['onDelete' => 'CASCADE']
1238
        );
1239
        $table->addForeignKeyConstraint(
1240
            $schema->getTable('orocrm_magento_website'),
1241
            ['website_id'],
1242
            ['id'],
1243
            ['onDelete' => 'CASCADE']
1244
        );
1245
    }
1246
1247
    /**
1248
     * Add orocrm_magento_website foreign keys.
1249
     *
1250
     * @param Schema $schema
1251
     */
1252 View Code Duplication
    protected function addOrocrmMagentoWebsiteForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1253
    {
1254
        $table = $schema->getTable('orocrm_magento_website');
1255
        $table->addForeignKeyConstraint(
1256
            $schema->getTable('oro_integration_channel'),
1257
            ['channel_id'],
1258
            ['id'],
1259
            ['onDelete' => 'SET NULL']
1260
        );
1261
    }
1262
1263
    /**
1264
     * Add orocrm_magento_cart foreign keys.
1265
     *
1266
     * @param Schema $schema
1267
     */
1268
    protected function addOrocrmMagentoCartForeignKeys(Schema $schema)
1269
    {
1270
        $table = $schema->getTable('orocrm_magento_cart');
1271
        $table->addForeignKeyConstraint(
1272
            $schema->getTable('orocrm_magento_customer'),
1273
            ['customer_id'],
1274
            ['id'],
1275
            ['onDelete' => 'CASCADE']
1276
        );
1277
        $table->addForeignKeyConstraint(
1278
            $schema->getTable('orocrm_magento_store'),
1279
            ['store_id'],
1280
            ['id'],
1281
            ['onDelete' => 'SET NULL']
1282
        );
1283
        $table->addForeignKeyConstraint(
1284
            $schema->getTable('orocrm_magento_cart_address'),
1285
            ['shipping_address_id'],
1286
            ['id'],
1287
            ['onDelete' => 'SET NULL']
1288
        );
1289
        $table->addForeignKeyConstraint(
1290
            $schema->getTable('orocrm_magento_cart_address'),
1291
            ['billing_address_id'],
1292
            ['id'],
1293
            ['onDelete' => 'SET NULL']
1294
        );
1295
        $table->addForeignKeyConstraint(
1296
            $schema->getTable('orocrm_magento_cart_status'),
1297
            ['status_name'],
1298
            ['name'],
1299
            ['onDelete' => 'SET NULL']
1300
        );
1301
        $table->addForeignKeyConstraint(
1302
            $schema->getTable('orocrm_sales_opportunity'),
1303
            ['opportunity_id'],
1304
            ['id'],
1305
            ['onDelete' => 'SET NULL']
1306
        );
1307
        $table->addForeignKeyConstraint(
1308
            $schema->getTable('oro_workflow_item'),
1309
            ['workflow_item_id'],
1310
            ['id'],
1311
            ['onDelete' => 'SET NULL']
1312
        );
1313
        $table->addForeignKeyConstraint(
1314
            $schema->getTable('oro_workflow_step'),
1315
            ['workflow_step_id'],
1316
            ['id'],
1317
            ['onDelete' => 'SET NULL']
1318
        );
1319
        $table->addForeignKeyConstraint(
1320
            $schema->getTable('oro_user'),
1321
            ['user_owner_id'],
1322
            ['id'],
1323
            ['onDelete' => 'SET NULL']
1324
        );
1325
        $table->addForeignKeyConstraint(
1326
            $schema->getTable('oro_integration_channel'),
1327
            ['channel_id'],
1328
            ['id'],
1329
            ['onDelete' => 'SET NULL']
1330
        );
1331
        $table->addForeignKeyConstraint(
1332
            $schema->getTable('orocrm_channel'),
1333
            ['data_channel_id'],
1334
            ['id'],
1335
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
1336
            'FK_96661A80BDC09B73'
1337
        );
1338
        $table->addForeignKeyConstraint(
1339
            $schema->getTable('oro_organization'),
1340
            ['organization_id'],
1341
            ['id'],
1342
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
1343
            'FK_96661A8032C8A3DE'
1344
        );
1345
    }
1346
1347
   
1348
1349
    /**
1350
     * Add orocrm_magento_cart_emails foreign keys.
1351
     *
1352
     * @param Schema $schema
1353
     */
1354 View Code Duplication
    protected function addOrocrmMagentoCartEmailsForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1355
    {
1356
        $table = $schema->getTable('orocrm_magento_cart_emails');
1357
        $table->addForeignKeyConstraint(
1358
            $schema->getTable('orocrm_magento_cart'),
1359
            ['cart_id'],
1360
            ['id'],
1361
            ['onDelete' => 'CASCADE']
1362
        );
1363
        $table->addForeignKeyConstraint(
1364
            $schema->getTable('oro_email'),
1365
            ['email_id'],
1366
            ['id'],
1367
            ['onDelete' => 'CASCADE']
1368
        );
1369
    }
1370
1371
    /**
1372
     * Add orocrm_magento_store foreign keys.
1373
     *
1374
     * @param Schema $schema
1375
     */
1376 View Code Duplication
    protected function addOrocrmMagentoStoreForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1377
    {
1378
        $table = $schema->getTable('orocrm_magento_store');
1379
        $table->addForeignKeyConstraint(
1380
            $schema->getTable('orocrm_magento_website'),
1381
            ['website_id'],
1382
            ['id'],
1383
            ['onDelete' => 'cascade']
1384
        );
1385
        $table->addForeignKeyConstraint(
1386
            $schema->getTable('oro_integration_channel'),
1387
            ['channel_id'],
1388
            ['id'],
1389
            ['onDelete' => 'SET NULL']
1390
        );
1391
    }
1392
1393
    /**
1394
     * Add orocrm_magento_order_items foreign keys.
1395
     *
1396
     * @param Schema $schema
1397
     */
1398 View Code Duplication
    protected function addOrocrmMagentoOrderItemsForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1399
    {
1400
        $table = $schema->getTable('orocrm_magento_order_items');
1401
        $table->addForeignKeyConstraint(
1402
            $schema->getTable('orocrm_magento_order'),
1403
            ['order_id'],
1404
            ['id'],
1405
            ['onDelete' => 'CASCADE']
1406
        );
1407
        $table->addForeignKeyConstraint(
1408
            $schema->getTable('oro_integration_channel'),
1409
            ['channel_id'],
1410
            ['id'],
1411
            ['onDelete' => 'SET NULL']
1412
        );
1413
        $table->addForeignKeyConstraint(
1414
            $schema->getTable('oro_organization'),
1415
            ['owner_id'],
1416
            ['id'],
1417
            ['onDelete' => 'SET NULL']
1418
        );
1419
    }
1420
1421
    /**
1422
     * Add orocrm_magento_newsl_subscr foreign keys.
1423
     *
1424
     * @param Schema $schema
1425
     */
1426 View Code Duplication
    protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
1427
    {
1428
        $table = $schema->getTable('orocrm_magento_newsl_subscr');
1429
        $table->addForeignKeyConstraint(
1430
            $schema->getTable('oro_organization'),
1431
            ['organization_id'],
1432
            ['id'],
1433
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
1434
        );
1435
        $table->addForeignKeyConstraint(
1436
            $schema->getTable('oro_user'),
1437
            ['owner_id'],
1438
            ['id'],
1439
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
1440
        );
1441
        $table->addForeignKeyConstraint(
1442
            $schema->getTable('orocrm_magento_customer'),
1443
            ['customer_id'],
1444
            ['id'],
1445
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
1446
        );
1447
        $table->addForeignKeyConstraint(
1448
            $schema->getTable('orocrm_magento_store'),
1449
            ['store_id'],
1450
            ['id'],
1451
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
1452
        );
1453
        $table->addForeignKeyConstraint(
1454
            $schema->getTable('oro_integration_channel'),
1455
            ['channel_id'],
1456
            ['id'],
1457
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
1458
        );
1459
        $table->addForeignKeyConstraint(
1460
            $schema->getTable('orocrm_channel'),
1461
            ['data_channel_id'],
1462
            ['id'],
1463
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
1464
        );
1465
    }
1466
1467
    /**
1468
     * Enable activities
1469
     *
1470
     * @param Schema $schema
1471
     */
1472
    protected function addActivityAssociations(Schema $schema)
1473
    {
1474
        $this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_magento_customer');
1475
        $this->activityExtension->addActivityAssociation($schema, 'orocrm_call', 'orocrm_magento_customer');
1476
        $this->activityExtension->addActivityAssociation($schema, 'orocrm_task', 'orocrm_magento_customer');
1477
        $this->activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_magento_customer');
1478
1479
        CreateActivityAssociation::addActivityAssociations($schema, $this->activityExtension);
1480
        OrderActivityAssociation::addActivityAssociations($schema, $this->activityExtension);
1481
    }
1482
1483
    /**
1484
     * @param Schema $schema
1485
     */
1486
    protected function addIdentifierEventAssociations(Schema $schema)
1487
    {
1488
        $this->identifierEventExtension->addIdentifierAssociation($schema, 'orocrm_magento_customer');
1489
        $this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_cart');
1490
        $this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_customer');
1491
        $this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_order');
1492
        $this->visitExtension->addVisitEventAssociation($schema, 'orocrm_magento_product');
1493
    }
1494
}
1495