|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Phinx\Migration\AbstractMigration; |
|
4
|
|
|
|
|
5
|
|
|
class Articles extends AbstractMigration |
|
6
|
|
|
{ |
|
7
|
|
|
public function up() |
|
8
|
|
|
{ |
|
9
|
|
|
$this->table('articles', ['id' => false, 'primary_key' => 'article_uuid']) |
|
10
|
|
|
->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
11
|
|
|
->addColumn('article_id', 'text') |
|
12
|
|
|
->addColumn('slug', 'text', ['null' => true]) |
|
13
|
|
|
->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
14
|
|
|
->addColumn('published_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
15
|
|
|
->addColumn('type', 'integer') // see Article\Entity\ArticleType |
|
16
|
|
|
->addColumn('status', 'integer') // active, not active, ... |
|
17
|
|
|
->addColumn('admin_user_uuid', 'binary', ['limit' => 16]) |
|
18
|
|
|
->addColumn('is_wysiwyg_editor', 'boolean', ['default' => false]) |
|
19
|
|
|
->addColumn('category_uuid', 'binary', ['limit' => 16]) |
|
20
|
|
|
->addForeignKey('category_uuid', 'category', 'category_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
21
|
|
|
->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
22
|
|
|
->addIndex('type', ['name' => 'type_INDEX']) |
|
23
|
|
|
->addIndex('published_at', ['name' => 'published_at_INDEX']) |
|
24
|
|
|
->create(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function down() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->dropTable('articles'); |
|
30
|
|
|
} |
|
31
|
|
|
} |
|
32
|
|
|
|