40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
||
|
||
use Phinx\Db\Adapter\MysqlAdapter;
|
||
use think\migration\Migrator;
|
||
use think\migration\db\Column;
|
||
|
||
class ArticleAddFieldCreate 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()
|
||
{
|
||
$table = $this->table('article');
|
||
$table
|
||
->addColumn('article_type_id','integer',['limit'=>10,'signed'=>false,'after'=>'site_id','default'=>0,'null'=>false,'comment'=>'文章分类ID'])
|
||
->addColumn('status','integer',['limit'=>MysqlAdapter::INT_TINY,'default'=>1,'after'=>'sort','null'=>false,'comment'=>'状态,0=启动,1=禁用'])
|
||
->changeColumn('detail','text',['comment'=>'文件详情'])
|
||
->update();
|
||
}
|
||
}
|