Blame view

console/migrations/m160316_134249_bookmarks_table.php 993 Bytes
14a09168   Alex Savenko   init 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
  <?php

  

      use yii\db\Migration;

  

      class m160316_134249_bookmarks_table extends Migration

      {

  

          public function up()

          {

              $this->createTable('{{%bookmark}}', [

                  'bookmark_id' => $this->primaryKey(),

                  'user_id'     => $this->integer()

                                        ->notNull(),

                  'model'       => $this->string()

                                        ->notNull(),

                  'model_id'    => $this->integer()

                                        ->notNull(),

                  'type'        => $this->integer()

                                        ->notNull(),

              ]);

              $this->addForeignKey('bookmark_user', '{{%bookmark}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE');

      }

  

          public function down()

          {

              $this->dropForeignKey('bookmark_user', '{{%bookmark}}');

              $this->dropTable('{{%bookmark}}');

          }

  

      }