虽然迁移回滚很简单,但它可能会导致生产db上的灾难。
我确信,在我的例子中,它只会回滚最后一个迁移文件,但我不能重复检查这个事实吗?
在运行迁移:回滚时,难道没有命令告诉我哪些迁移文件将被回滚吗?
发布于 2016-04-02 14:35:10
没有这样的命令,但是您可以使用创建自己的命令 (这确实是一个非常简单的任务,will花了大约5分钟)并对一个迁移表使用简单的查询,例如:
public function handle()
{
$lastMigration = \DB::table('migrations')->orderBy('batch', 'DESC')->first();
$lastBatch = $lastMigration->batch; // last batch ID
$migrations = \DB::table('migrations')->where('batch', $lastBatch);
foreach ($migrations as $migration) {
$this->info($migration->migration); // output current migration name to cli
}
}发布于 2016-04-02 14:36:47
您可以查看数据库中迁移表中批处理列中的“批处理”号。最新一批迁移将被回滚。
https://stackoverflow.com/questions/36374452
复制相似问题