Completed
Push — master ( a18731...e2e070 )
by
unknown
99:54 queued 47:45
created

addOrocrmMagentoCartForeignKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 66
Code Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 66
rs 9.3191
c 0
b 0
f 0
cc 1
eloc 54
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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