使用thinkphp 5.1的migration时定义了down方法还提示No migrations to rollback?

学习使用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();
    }
}

请大神指点,谢谢啦~

阅读 2.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题