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

@@ 512-552 (lines=41) @@
509
     *
510
     * @param Schema $schema
511
     */
512
    protected function addOrocrmSalesOpportunityForeignKeys(Schema $schema)
513
    {
514
        $table = $schema->getTable('orocrm_sales_opportunity');
515
        $table->addForeignKeyConstraint(
516
            $schema->getTable('orocrm_contact'),
517
            ['contact_id'],
518
            ['id'],
519
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
520
        );
521
        $table->addForeignKeyConstraint(
522
            $schema->getTable('orocrm_sales_opport_close_rsn'),
523
            ['close_reason_name'],
524
            ['name'],
525
            ['onUpdate' => null, 'onDelete' => null]
526
        );
527
        $table->addForeignKeyConstraint(
528
            $schema->getTable('oro_user'),
529
            ['user_owner_id'],
530
            ['id'],
531
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
532
        );
533
        $table->addForeignKeyConstraint(
534
            $schema->getTable('orocrm_sales_b2bcustomer'),
535
            ['customer_id'],
536
            ['id'],
537
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
538
        );
539
        $table->addForeignKeyConstraint(
540
            $schema->getTable('orocrm_channel'),
541
            ['data_channel_id'],
542
            ['id'],
543
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
544
            'FK_C0FE4AACBDC09B73'
545
        );
546
        $table->addForeignKeyConstraint(
547
            $schema->getTable('orocrm_sales_lead'),
548
            ['lead_id'],
549
            ['id'],
550
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
551
        );
552
    }
553
554
    /**
555
     * Add orocrm_sales_funnel foreign keys.
@@ 594-634 (lines=41) @@
591
     *
592
     * @param Schema $schema
593
     */
594
    protected function addOrocrmSalesLeadForeignKeys(Schema $schema)
595
    {
596
        $table = $schema->getTable('orocrm_sales_lead');
597
        $table->addForeignKeyConstraint(
598
            $schema->getTable('orocrm_campaign'),
599
            ['campaign_id'],
600
            ['id'],
601
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
602
        );
603
        $table->addForeignKeyConstraint(
604
            $schema->getTable('oro_address'),
605
            ['address_id'],
606
            ['id'],
607
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
608
        );
609
        $table->addForeignKeyConstraint(
610
            $schema->getTable('orocrm_contact'),
611
            ['contact_id'],
612
            ['id'],
613
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
614
        );
615
        $table->addForeignKeyConstraint(
616
            $schema->getTable('oro_user'),
617
            ['user_owner_id'],
618
            ['id'],
619
            ['onUpdate' => null, 'onDelete' => 'SET NULL']
620
        );
621
        $table->addForeignKeyConstraint(
622
            $schema->getTable('orocrm_sales_b2bcustomer'),
623
            ['customer_id'],
624
            ['id'],
625
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
626
        );
627
        $table->addForeignKeyConstraint(
628
            $schema->getTable('orocrm_channel'),
629
            ['data_channel_id'],
630
            ['id'],
631
            ['onDelete' => 'SET NULL', 'onUpdate' => null],
632
            'FK_73DB4633BDC09B73'
633
        );
634
    }
635
636
    /**
637
     * Add orocrm_sales_b2bcustomer foreign keys.
@@ 641-680 (lines=40) @@
638
     *
639
     * @param Schema $schema
640
     */
641
    protected function addOrocrmSalesB2bCustomerForeignKeys(Schema $schema)
642
    {
643
        $table = $schema->getTable('orocrm_sales_b2bcustomer');
644
        $table->addForeignKeyConstraint(
645
            $schema->getTable('oro_user'),
646
            ['user_owner_id'],
647
            ['id'],
648
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
649
        );
650
        $table->addForeignKeyConstraint(
651
            $schema->getTable('oro_address'),
652
            ['shipping_address_id'],
653
            ['id'],
654
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
655
        );
656
        $table->addForeignKeyConstraint(
657
            $schema->getTable('orocrm_channel'),
658
            ['data_channel_id'],
659
            ['id'],
660
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
661
        );
662
        $table->addForeignKeyConstraint(
663
            $schema->getTable('oro_address'),
664
            ['billing_address_id'],
665
            ['id'],
666
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
667
        );
668
        $table->addForeignKeyConstraint(
669
            $schema->getTable('orocrm_account'),
670
            ['account_id'],
671
            ['id'],
672
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
673
        );
674
        $table->addForeignKeyConstraint(
675
            $schema->getTable('orocrm_contact'),
676
            ['contact_id'],
677
            ['id'],
678
            ['onDelete' => 'SET NULL', 'onUpdate' => null]
679
        );
680
    }
681
682
    /**
683
     * Add opportunity status Enum field and initialize default enum values