Blame view

migrations/m170503_141153_create_order_table.php 1.63 KB
11ecfb79   Yarik   Basket
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;
      
      /**
       * Handles the creation of table `order`.
       */
      class m170503_141153_create_order_table extends Migration
      {
          /**
           * @inheritdoc
           */
          public function up()
          {
              $this->createTable(
                  'order',
                  [
                      'id'          => $this->primaryKey(),
                      'user_id'     => $this->integer(),
                      'name'        => $this->string(),
                      'phone'       => $this->string(),
                      'email'       => $this->string(),
                      'city'        => $this->string(),
                      'address'     => $this->string(),
                      'comment'     => $this->string(),
                      'label_id'    => $this->integer()
                                            ->notNull(),
                      'delivery_id' => $this->integer()
                                            ->notNull(),
                      'payment_id'  => $this->integer()
                                            ->notNull(),
                      'created_at'  => $this->integer(),
                      'updated_at'  => $this->integer(),
                      'deleted_at'  => $this->integer(),
                  ]
              );
              
              $this->addForeignKey('order_user_id_fkey', 'order', 'user_id', 'customer', 'id', 'RESTRICT', 'CASCADE');
          }
          
          /**
           * @inheritdoc
           */
          public function down()
          {
              $this->dropForeignKey('order_user_id_fkey', 'order');
              
              $this->dropTable('order');
          }
      }