Blame view

migrations/m170615_080920_odoo_remote_tables.php 3.86 KB
714f42c5   Yarik   Odoo completed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  <?php
      
      use yii\db\Migration;
      
      class m170615_080920_odoo_remote_tables extends Migration
      {
          public function safeUp()
          {
              $this->createTable(
                  'odoo_to_product',
                  [
                      'product_id' => $this->integer()
                                           ->notNull(),
                      'remote_id'  => $this->integer()
                                           ->notNull(),
                  ]
              );
              
              $this->createIndex(
                  'odoo_to_product_uindex',
                  'odoo_to_product',
                  [
                      'product_id',
                      'remote_id',
                  ],
                  true
              );
              
              $this->addForeignKey(
                  'odoo_to_product_product_fkey',
                  'odoo_to_product',
                  'product_id',
                  'product',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
              
              $this->createTable(
                  'odoo_to_order',
                  [
                      'order_id'  => $this->integer()
                                          ->notNull(),
                      'remote_id' => $this->integer()
                                          ->notNull(),
                  ]
              );
              
              $this->createIndex(
                  'odoo_to_order_uindex',
                  'odoo_to_order',
                  [
                      'order_id',
                      'remote_id',
                  ],
                  true
              );
              
              $this->addForeignKey(
                  'odoo_to_order_order_fkey',
                  'odoo_to_order',
                  'order_id',
                  'order',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
              
              $this->createTable(
                  'odoo_to_category',
                  [
                      'category_id' => $this->integer()
                                            ->notNull(),
                      'remote_id'   => $this->integer()
                                            ->notNull(),
                  ]
              );
              
              $this->createIndex(
                  'odoo_to_category_uindex',
                  'odoo_to_category',
                  [
                      'category_id',
                      'remote_id',
                  ],
                  true
              );
              
              $this->addForeignKey(
                  'odoo_to_category_category_fkey',
                  'odoo_to_category',
                  'category_id',
                  'category',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
              
              $this->createTable(
                  'odoo_to_customer',
                  [
                      'customer_id' => $this->integer()
                                            ->notNull(),
                      'remote_id'   => $this->integer()
                                            ->notNull(),
                  ]
              );
              
              $this->createIndex(
                  'odoo_to_customer_uindex',
                  'odoo_to_customer',
                  [
                      'customer_id',
                      'remote_id',
                  ],
                  true
              );
              
              $this->addForeignKey(
                  'odoo_to_customer_customer_fkey',
                  'odoo_to_customer',
                  'customer_id',
                  'customer',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
          }
          
          public function safeDown()
          {
              $this->dropTable('odoo_to_order');
              $this->dropTable('odoo_to_product');
              $this->dropTable('odoo_to_category');
              $this->dropTable('odoo_to_customer');
          }
      }