回滚Laravel中的一个特定迁移 [英] Rollback one specific migration in Laravel

查看:142
本文介绍了回滚Laravel中的一个特定迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅回滚:

Rolled back: 2015_05_15_195423_alter_table_web_directories

php artisan migrate:rollback,我的3个迁移正在回滚.

php artisan migrate:rollback, 3 of my migration are rolling back.

Rolled back: 2015_05_15_195423_alter_table_web_directories
Rolled back: 2015_05_13_135240_create_web_directories_table
Rolled back: 2015_05_13_134411_create_contacts_table


我删除

我的web_directoriescontacts表中的

都是无意的.我从来不希望这种情况发生,而且如果我只能回滚特定的事件,那么这种灾难将永远不会发生.


I delete

both of my web_directories and my contacts table unintentionally. I never want that to happen, and if I can rollback only that specific one, this disaster will never happen.

推荐答案

如果您查看migrations表,则将看到每个迁移都有一个批号.因此,当您回滚时,它会回滚最后一批中的每个迁移.

If you look in your migrations table, then you’ll see each migration has a batch number. So when you roll back, it rolls back each migration that was part of the last batch.

如果您只想回滚最后一次迁移,则只需将批号加1.然后,下次您运行rollback命令时,它只会回滚该迁移,因为它位于其自己的批处理"中.

If you only want to roll back the very last migration, then just increment the batch number by one. Then next time you run the rollback command, it’ll only roll back that one migration as it’s in a "batch" of its own.

这篇关于回滚Laravel中的一个特定迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆