Blame view

console/migrations/m170613_075310_create_slider_table.php 1.25 KB
950817c6   Alex Savenko   first commit
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
  <?php
      
      use yii\db\Migration;
      
      /**
       * Handles the creation of table `slider`.
       */
      class m170613_075310_create_slider_table extends Migration
      {
          /**
           * @inheritdoc
           */
          public function up()
          {
              $this->createTable(
                  'slider',
                  [
                      'id'       => $this->primaryKey(),
                      'image_id' => $this->integer()
                                         ->notNull(),
                      'link'     => $this->string(),
                      'status'   => $this->boolean()
                                         ->defaultValue(true),
                      'sort'     => $this->integer()
                                         ->defaultValue(0),
                  ]
              );
              $this->addForeignKey(
                  'slider_image_id_fkey',
                  'slider',
                  'image_id',
                  'ImageManager',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
          }
          
          /**
           * @inheritdoc
           */
          public function down()
          {
              $this->dropForeignKey('slider_image_id_fkey', 'slider');
              $this->dropTable('slider');
          }
      }