Blame view

console/migrations/m160304_081817_rating_table.php 808 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
  <?php

  

  use yii\db\Migration;

  

  class m160304_081817_rating_table extends Migration

  {

      public function up()

      {

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

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

              'date_add' => $this->timestamp()->notNull()->defaultExpression('NOW()'),

              'date_update' => $this->timestamp()->notNull()->defaultExpression('NOW()'),

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

              'entity' => $this->string(),

              'value' => $this->integer(),

          ]);

  

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

      }

  

      public function down()

      {

          $this->dropForeignKey('rating_user', '{{%rating}}');

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

      }

  

  }