Code Duplication    Length = 40-42 lines in 8 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/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

@@ 1397-1436 (lines=40) @@
1394
     *
1395
     * @param Schema $schema
1396
     */
1397
    protected function addOrocrmMagentoNewslSubscrForeignKeys(Schema $schema)
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

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

@@ 486-526 (lines=41) @@
483
     *
484
     * @param Schema $schema
485
     */
486
    protected function addOrocrmSalesOpportunityForeignKeys(Schema $schema)
487
    {
488
        $table = $schema->getTable('orocrm_sales_opportunity');
489
        $table->addForeignKeyConstraint(
490
            $schema->getTable('orocrm_contact'),
491
            ['contact_id'],
492
            ['id'],
493
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
494
        );
495
        $table->addForeignKeyConstraint(
496
            $schema->getTable('orocrm_sales_opport_close_rsn'),
497
            ['close_reason_name'],
498
            ['name'],
499
            ['onUpdate' => null, 'onDelete' => null]
500
        );
501
        $table->addForeignKeyConstraint(
502
            $schema->getTable('oro_user'),
503
            ['user_owner_id'],
504
            ['id'],
505
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
506
        );
507
        $table->addForeignKeyConstraint(
508
            $schema->getTable('orocrm_sales_b2bcustomer'),
509
            ['customer_id'],
510
            ['id'],
511
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
512
        );
513
        $table->addForeignKeyConstraint(
514
            $schema->getTable('orocrm_channel'),
515
            ['data_channel_id'],
516
            ['id'],
517
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
518
            'FK_C0FE4AACBDC09B73'
519
        );
520
        $table->addForeignKeyConstraint(
521
            $schema->getTable('orocrm_sales_lead'),
522
            ['lead_id'],
523
            ['id'],
524
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
525
        );
526
    }
527
528
    /**
529
     * Add orocrm_sales_funnel foreign keys.
@@ 568-608 (lines=41) @@
565
     *
566
     * @param Schema $schema
567
     */
568
    protected function addOrocrmSalesLeadForeignKeys(Schema $schema)
569
    {
570
        $table = $schema->getTable('orocrm_sales_lead');
571
        $table->addForeignKeyConstraint(
572
            $schema->getTable('orocrm_campaign'),
573
            ['campaign_id'],
574
            ['id'],
575
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
576
        );
577
        $table->addForeignKeyConstraint(
578
            $schema->getTable('oro_address'),
579
            ['address_id'],
580
            ['id'],
581
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
582
        );
583
        $table->addForeignKeyConstraint(
584
            $schema->getTable('orocrm_contact'),
585
            ['contact_id'],
586
            ['id'],
587
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
588
        );
589
        $table->addForeignKeyConstraint(
590
            $schema->getTable('oro_user'),
591
            ['user_owner_id'],
592
            ['id'],
593
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
594
        );
595
        $table->addForeignKeyConstraint(
596
            $schema->getTable('orocrm_sales_b2bcustomer'),
597
            ['customer_id'],
598
            ['id'],
599
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
600
        );
601
        $table->addForeignKeyConstraint(
602
            $schema->getTable('orocrm_channel'),
603
            ['data_channel_id'],
604
            ['id'],
605
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
606
            'FK_73DB4633BDC09B73'
607
        );
608
    }
609
610
    /**
611
     * Add orocrm_sales_b2bcustomer foreign keys.
@@ 615-654 (lines=40) @@
612
     *
613
     * @param Schema $schema
614
     */
615
    protected function addOrocrmSalesB2bCustomerForeignKeys(Schema $schema)
616
    {
617
        $table = $schema->getTable('orocrm_sales_b2bcustomer');
618
        $table->addForeignKeyConstraint(
619
            $schema->getTable('oro_user'),
620
            ['user_owner_id'],
621
            ['id'],
622
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
623
        );
624
        $table->addForeignKeyConstraint(
625
            $schema->getTable('oro_address'),
626
            ['shipping_address_id'],
627
            ['id'],
628
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
629
        );
630
        $table->addForeignKeyConstraint(
631
            $schema->getTable('orocrm_channel'),
632
            ['data_channel_id'],
633
            ['id'],
634
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
635
        );
636
        $table->addForeignKeyConstraint(
637
            $schema->getTable('oro_address'),
638
            ['billing_address_id'],
639
            ['id'],
640
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
641
        );
642
        $table->addForeignKeyConstraint(
643
            $schema->getTable('orocrm_account'),
644
            ['account_id'],
645
            ['id'],
646
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
647
        );
648
        $table->addForeignKeyConstraint(
649
            $schema->getTable('orocrm_contact'),
650
            ['contact_id'],
651
            ['id'],
652
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
653
        );
654
    }
655
656
    /**
657
     * Add opportunity status Enum field and initialize default enum values