且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

回滚laravel5中的特定迁移

更新时间:2022-03-10 05:07:06

迁移是按特定顺序应用和回滚的.因此,没有重新应用任意迁移的适当"方法.

Migrations are meant to be applied and rolled back in a specific order. Therefore there is no "proper" way of reapplying an arbitrary migration.

无论如何,至少有两个选择:

In any case there are at least two options:

  1. 故障转移"-创建后续迁移,以创建必要的FK并将其应用.如果您已经投入生产,这是唯一正确的方法.

  1. "Fail forward" - create a subsequent migration that creates a necessary FK and apply it. This is the only proper way if you are already in production.

如果您还处于开发的初期阶段,并且不to肿迁移目录,那么您可以

If you're just in early stages of development and don't won't to bloat the migrations directory you can

  • 转储表,以便保留数据
  • 回滚到此特定迁移
  • 修复并测试迁移
  • 迁移
  • 从转储中加载数据