学习使用tp5的数据迁移,在类中定义了up和down方法,在命令行执行php think migrate:run
可以按预期执行,但是在执行php think migrate:rollback
时提示No migrations to rollback
截图:
实现代码如下:
<?php
use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;
class BannerModifyField 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 up()
{
$table = $this->table('banner',array('engine'=>'Innodb'));
$table->changeColumn('create_time', 'integer',array('limit' => MysqlAdapter::INT_REGULAR, 'signed'=>false, 'comment'=>'创建时间'))
->changeColumn('update_time', 'integer',array('limit' => MysqlAdapter::INT_REGULAR, 'signed'=>false, 'comment'=>'修改时间'))
->update();
}
public function down()
{
$table = $this->table('banner',array('engine'=>'Innodb'));
$table->changeColumn('create_time', 'integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment'=>'创建时间'))
->changeColumn('update_time', 'integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment'=>'修改时间'))
->update();
}
}
请大神指点,谢谢啦~