Blame view

artweb/artbox-catalog/migrations/m170405_000009_variant.php 1.62 KB
16f1e516   mzavalniuk   add artbox-catalo...
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
  <?php
      
      use yii\db\Migration;
      
      class m170405_000009_variant extends Migration
      {
          public function safeUp()
          {
              $this->createTable(
                  'variant',
                  [
                      'id'         => $this->primaryKey(),
                      'product_id' => $this->integer()
                                           ->notNull(),
                      'sku'        => $this->string()
                                           ->notNull(),
                      'price'      => $this->decimal(),
                      'price_old'  => $this->decimal(),
                      'stock'      => $this->integer()
                                           ->notNull()
                                           ->defaultValue(0),
                      'status'     => $this->boolean()
                                           ->defaultValue(true),
                      'sort'       => $this->integer()
                                           ->defaultValue(0),
                      'created_at' => $this->integer(),
                      'updated_at' => $this->integer(),
                  ]
              );
              
              $this->addForeignKey(
                  'variant_product_id_to_product_fk',
                  'variant',
                  'product_id',
                  'product',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
          }
          
          public function safeDown()
          {
              $this->dropForeignKey(
                  'variant_product_id_to_product_fk',
                  'variant'
              );
              $this->dropTable('variant');
          }
      }