Blame view

console/migrations/m160225_143331_comment_test.php 1.17 KB
b82db04a   Yarik   test
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
  <?php
  
  use yii\db\Migration;
  
  class m160225_143331_comment_test extends Migration
  {
      public function up()
      {
          $this->createTable('{{%comment}}', [
              'comment_id' => $this->primaryKey(),
              'entity' => $this->string()->notNull(),
              'text' => $this->text()->notNull(),
              'user_id' => $this->integer(),
              'user_name' => $this->string(),
              'user_email' => $this->string(),
              'comment_pid' => $this->integer(),
              'status' => $this->integer(),
              'date_add' => $this->timestamp()->notNull()->defaultExpression('NOW()'),
              'date_update' => $this->timestamp()->notNull()->defaultExpression('NOW()'),
              'date_delete' => $this->timestamp(),
          ]);
  
          $this->addForeignKey('comment_user', '{{%comment}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE');
      }
  
      public function down()
      {
          $this->dropForeignKey('comment_user', '{{%comment}}');
          $this->dropTable('{{%comment}}');
      }
  
      /*
      // Use safeUp/safeDown to run migration code within a transaction
      public function safeUp()
      {
      }
  
      public function safeDown()
      {
      }
      */
  }