44 lines
1.7 KiB
PHP
44 lines
1.7 KiB
PHP
<?php
|
|
|
|
use think\migration\Migrator;
|
|
use think\migration\db\Column;
|
|
|
|
class ArticleCates extends Migrator
|
|
{
|
|
/**
|
|
* Change Method.
|
|
*
|
|
* Write your reversible migrations using this method.
|
|
*
|
|
* More information on writing migrations is available here:
|
|
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
|
*
|
|
* The following commands can be used in this method and Phinx will
|
|
* automatically reverse them when rolling back:
|
|
*
|
|
* createTable
|
|
* renameTable
|
|
* addColumn
|
|
* renameColumn
|
|
* addIndex
|
|
* addForeignKey
|
|
*
|
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
|
* with the Table class.
|
|
*/
|
|
public function change()
|
|
{
|
|
$this->table('article_cates')->drop()->save();
|
|
$this->table('article_cates', ['comment' => '文章分类表'])
|
|
->addColumn('title', 'string', ['limit' => 50, 'null' => false, 'comment' => '分类名称'])
|
|
->addColumn('sort', 'integer', ['default' => 0, 'null' => false, 'comment' => '排序'])
|
|
->addColumn('status', 'boolean', ['default' => 1, 'null' => false, 'comment' => '状态 1:启用 0:禁用'])
|
|
->addColumn('create_time', 'integer', ['null' => true, 'comment' => '创建时间'])
|
|
->addColumn('update_time', 'integer', ['null' => true, 'comment' => '更新时间'])
|
|
->addIndex(['title'], ['unique' => true, 'name' => 'idx_title'])
|
|
->addIndex(['status','sort'], ['name' => 'idx_status_sort'])
|
|
->addIndex(['create_time','sort'], ['name' => 'idx_create_time_sort'])
|
|
->save();
|
|
}
|
|
}
|