|
1
|
|
|
<?php |
|
2
|
|
|
use App\Db\Migration; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Class m190731_024219_table_article |
|
6
|
|
|
*/ |
|
7
|
|
|
class m190731_024219_table_article extends Migration |
|
8
|
|
|
{ |
|
9
|
|
|
private $tableName = '{{%article}}'; |
|
10
|
|
|
|
|
11
|
|
|
public function safeUp() |
|
12
|
|
|
{ |
|
13
|
|
|
$this->createTable($this->tableName, [ |
|
14
|
|
|
'id' => $this->primaryKey(), |
|
15
|
|
|
'category_id' => $this->integer()->notNull()->comment('Category ID'), |
|
16
|
|
|
'creator' => $this->integer()->notNull()->comment('Creator ID'), |
|
17
|
|
|
'title' => $this->string()->notNull()->comment('Title'), |
|
18
|
|
|
'author' => $this->string()->notNull()->defaultValue('')->comment('Author'), |
|
19
|
|
|
'summary' => $this->string()->notNull()->comment('Summary'), |
|
20
|
|
|
'cover' => $this->string()->notNull()->comment('Cover'), |
|
21
|
|
|
'status' => $this->status(), |
|
22
|
|
|
'is_deleted' => $this->softDelete(), |
|
23
|
|
|
'views' => $this->integer()->unsigned()->notNull()->defaultValue(0), |
|
24
|
|
|
'version' => $this->optimisticLock(), |
|
25
|
|
|
'release_time' => $this->timestamp('Release Time'), |
|
26
|
|
|
'create_time' => $this->createTimestamp(), |
|
27
|
|
|
'update_time' => $this->updateTimestamp(), |
|
28
|
|
|
], $this->tableOptions()); |
|
29
|
|
|
|
|
30
|
|
|
$this->createIndex('article_idx_creator', $this->tableName, ['creator']); |
|
31
|
|
|
$this->createIndex('article_idx_status', $this->tableName, ['status']); |
|
32
|
|
|
$this->createIndex('article_idx_is_deleted', $this->tableName, ['is_deleted']); |
|
33
|
|
|
$this->createIndex('article_idx_release_time', $this->tableName, ['release_time']); |
|
34
|
|
|
$this->createIndex('article_idx_category_id', $this->tableName, 'category_id'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function safeDown() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->dropTable($this->tableName); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|