Skip to content

Commit

Permalink
Add article comment migration
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Aug 29, 2019
1 parent 0d3e8a0 commit 6919a88
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions resources/migrations/m190829_093604_article_comment.php
@@ -0,0 +1,34 @@
<?php
use App\Db\Migration;

/**
* Class m190829_093604_article_comment
*/
class m190829_093604_article_comment extends Migration
{
private $tableName = '{{%article_comment}}';

public function safeUp()
{
$this->createTable($this->tableName, [
'id' => $this->bigPrimaryKey(),
'reply_to' => $this->bigInteger()->notNull()->defaultValue(0)->comment('Reply To'),
'article_id' => $this->integer()->notNull()->comment('Article ID'),
'user_id' => $this->integer()->notNull()->comment('User ID'),
'content' => $this->text()->notNull()->comment('Content'),
'is_deleted' => $this->softDelete(),
'create_time' => $this->createTimestamp(),
'update_time' => $this->updateTimestamp(),
], $this->tableOptions());

$this->createIndex('article_comment_idx_reply_to', $this->tableName, 'reply_to');
$this->createIndex('article_comment_idx_article_id', $this->tableName, 'article_id');
$this->createIndex('article_comment_idx_user_id', $this->tableName, 'user_id');
$this->createIndex('article_comment_idx_create_time', $this->tableName, 'create_time');
}

public function safeDown()
{
$this->dropTable($this->tableName);
}
}

0 comments on commit 6919a88

Please sign in to comment.