Code Duplication    Length = 40-42 lines in 7 locations

src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/v1_0/OroCRMMagentoBundle.php 2 locations

@@ 797-838 (lines=42) @@
794
     *
795
     * @param Schema $schema
796
     */
797
    public static function orocrmMagentoCustomerForeignKeys(Schema $schema)
798
    {
799
        /** Generate foreign keys for table orocrm_magento_customer **/
800
        $table = $schema->getTable('orocrm_magento_customer');
801
        $table->addForeignKeyConstraint(
802
            $schema->getTable('oro_integration_channel'),
803
            ['channel_id'],
804
            ['id'],
805
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
806
        );
807
        $table->addForeignKeyConstraint(
808
            $schema->getTable('orocrm_magento_website'),
809
            ['website_id'],
810
            ['id'],
811
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
812
        );
813
        $table->addForeignKeyConstraint(
814
            $schema->getTable('orocrm_account'),
815
            ['account_id'],
816
            ['id'],
817
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
818
        );
819
        $table->addForeignKeyConstraint(
820
            $schema->getTable('orocrm_magento_store'),
821
            ['store_id'],
822
            ['id'],
823
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
824
        );
825
        $table->addForeignKeyConstraint(
826
            $schema->getTable('orocrm_magento_customer_group'),
827
            ['customer_group_id'],
828
            ['id'],
829
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
830
        );
831
        $table->addForeignKeyConstraint(
832
            $schema->getTable('orocrm_contact'),
833
            ['contact_id'],
834
            ['id'],
835
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
836
        );
837
        /** End of generate foreign keys for table orocrm_magento_customer **/
838
    }
839
840
    /**
841
     * Generate foreign keys for table orocrm_magento_customer_address
@@ 923-964 (lines=42) @@
920
     *
921
     * @param Schema $schema
922
     */
923
    public static function orocrmMagentoOrderForeignKeys(Schema $schema)
924
    {
925
        /** Generate foreign keys for table orocrm_magento_order **/
926
        $table = $schema->getTable('orocrm_magento_order');
927
        $table->addForeignKeyConstraint(
928
            $schema->getTable('oro_integration_channel'),
929
            ['channel_id'],
930
            ['id'],
931
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
932
        );
933
        $table->addForeignKeyConstraint(
934
            $schema->getTable('oro_workflow_item'),
935
            ['workflow_item_id'],
936
            ['id'],
937
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
938
        );
939
        $table->addForeignKeyConstraint(
940
            $schema->getTable('orocrm_magento_cart'),
941
            ['cart_id'],
942
            ['id'],
943
            ['onDelete' => null, 'onUpdate' => null]
944
        );
945
        $table->addForeignKeyConstraint(
946
            $schema->getTable('oro_workflow_step'),
947
            ['workflow_step_id'],
948
            ['id'],
949
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
950
        );
951
        $table->addForeignKeyConstraint(
952
            $schema->getTable('orocrm_magento_customer'),
953
            ['customer_id'],
954
            ['id'],
955
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
956
        );
957
        $table->addForeignKeyConstraint(
958
            $schema->getTable('orocrm_magento_store'),
959
            ['store_id'],
960
            ['id'],
961
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
962
        );
963
        /** End of generate foreign keys for table orocrm_magento_order **/
964
    }
965
966
    /**
967
     * Generate foreign keys for table orocrm_magento_order_address

src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/v1_30/AddNewsletterSubscriber.php 1 location

@@ 81-120 (lines=40) @@
78
     *
79
     * @param Schema $schema
80
     */
81
    protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema)
82
    {
83
        $table = $schema->getTable('orocrm_magento_newsl_subscr');
84
        $table->addForeignKeyConstraint(
85
            $schema->getTable('oro_organization'),
86
            ['organization_id'],
87
            ['id'],
88
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
89
        );
90
        $table->addForeignKeyConstraint(
91
            $schema->getTable('oro_user'),
92
            ['owner_id'],
93
            ['id'],
94
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
95
        );
96
        $table->addForeignKeyConstraint(
97
            $schema->getTable('orocrm_magento_customer'),
98
            ['customer_id'],
99
            ['id'],
100
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
101
        );
102
        $table->addForeignKeyConstraint(
103
            $schema->getTable('orocrm_magento_store'),
104
            ['store_id'],
105
            ['id'],
106
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
107
        );
108
        $table->addForeignKeyConstraint(
109
            $schema->getTable('oro_integration_channel'),
110
            ['channel_id'],
111
            ['id'],
112
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
113
        );
114
        $table->addForeignKeyConstraint(
115
            $schema->getTable('orocrm_channel'),
116
            ['data_channel_id'],
117
            ['id'],
118
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
119
        );
120
    }
121
}
122

src/OroCRM/Bundle/SalesBundle/Migrations/Schema/OroCRMSalesBundleInstaller.php 2 locations

@@ 493-533 (lines=41) @@
490
     *
491
     * @param Schema $schema
492
     */
493
    protected function addOrocrmSalesFunnelForeignKeys(Schema $schema)
494
    {
495
        $table = $schema->getTable('orocrm_sales_funnel');
496
        $table->addForeignKeyConstraint(
497
            $schema->getTable('oro_user'),
498
            ['user_owner_id'],
499
            ['id'],
500
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
501
        );
502
        $table->addForeignKeyConstraint(
503
            $schema->getTable('orocrm_sales_opportunity'),
504
            ['opportunity_id'],
505
            ['id'],
506
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
507
        );
508
        $table->addForeignKeyConstraint(
509
            $schema->getTable('orocrm_sales_lead'),
510
            ['lead_id'],
511
            ['id'],
512
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
513
        );
514
        $table->addForeignKeyConstraint(
515
            $schema->getTable('oro_workflow_item'),
516
            ['workflow_item_id'],
517
            ['id'],
518
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
519
        );
520
        $table->addForeignKeyConstraint(
521
            $schema->getTable('oro_workflow_step'),
522
            ['workflow_step_id'],
523
            ['id'],
524
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
525
        );
526
        $table->addForeignKeyConstraint(
527
            $schema->getTable('orocrm_channel'),
528
            ['data_channel_id'],
529
            ['id'],
530
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
531
            'FK_E20C7344BDC09B73'
532
        );
533
    }
534
535
    /**
536
     * Add orocrm_sales_lead foreign keys.
@@ 605-644 (lines=40) @@
602
     *
603
     * @param Schema $schema
604
     */
605
    protected function addOrocrmSalesB2bCustomerForeignKeys(Schema $schema)
606
    {
607
        $table = $schema->getTable('orocrm_sales_b2bcustomer');
608
        $table->addForeignKeyConstraint(
609
            $schema->getTable('oro_user'),
610
            ['user_owner_id'],
611
            ['id'],
612
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
613
        );
614
        $table->addForeignKeyConstraint(
615
            $schema->getTable('oro_address'),
616
            ['shipping_address_id'],
617
            ['id'],
618
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
619
        );
620
        $table->addForeignKeyConstraint(
621
            $schema->getTable('orocrm_channel'),
622
            ['data_channel_id'],
623
            ['id'],
624
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
625
        );
626
        $table->addForeignKeyConstraint(
627
            $schema->getTable('oro_address'),
628
            ['billing_address_id'],
629
            ['id'],
630
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
631
        );
632
        $table->addForeignKeyConstraint(
633
            $schema->getTable('orocrm_account'),
634
            ['account_id'],
635
            ['id'],
636
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
637
        );
638
        $table->addForeignKeyConstraint(
639
            $schema->getTable('orocrm_contact'),
640
            ['contact_id'],
641
            ['id'],
642
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
643
        );
644
    }
645
646
    /**
647
     * Create oro_email_mailbox_processor table

src/OroCRM/Bundle/SalesBundle/Migrations/Schema/v1_10/OroCRMSalesBundle.php 1 location

@@ 123-162 (lines=40) @@
120
     *
121
     * @param Schema $schema
122
     */
123
    protected function addOrocrmSalesB2bCustomerForeignKeys(Schema $schema)
124
    {
125
        $table = $schema->getTable('orocrm_sales_b2bcustomer');
126
        $table->addForeignKeyConstraint(
127
            $schema->getTable('oro_user'),
128
            ['user_owner_id'],
129
            ['id'],
130
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
131
        );
132
        $table->addForeignKeyConstraint(
133
            $schema->getTable('oro_address'),
134
            ['shipping_address_id'],
135
            ['id'],
136
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
137
        );
138
        $table->addForeignKeyConstraint(
139
            $schema->getTable('orocrm_channel'),
140
            ['data_channel_id'],
141
            ['id'],
142
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
143
        );
144
        $table->addForeignKeyConstraint(
145
            $schema->getTable('oro_address'),
146
            ['billing_address_id'],
147
            ['id'],
148
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
149
        );
150
        $table->addForeignKeyConstraint(
151
            $schema->getTable('orocrm_account'),
152
            ['account_id'],
153
            ['id'],
154
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
155
        );
156
        $table->addForeignKeyConstraint(
157
            $schema->getTable('orocrm_contact'),
158
            ['contact_id'],
159
            ['id'],
160
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
161
        );
162
    }
163
}
164

src/OroCRM/Bundle/MagentoBundle/Migrations/Schema/OroCRMMagentoBundleInstaller.php 1 location

@@ 1426-1465 (lines=40) @@
1423
     *
1424
     * @param Schema $schema
1425
     */
1426
    protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema)
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