回滚laravel5中的特定迁移 [英] Rollback a specific migration in laravel5

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

问题描述

我需要回滚特定的表,因为我忘了提到外键了. 而且我不希望所有表中的数据丢失.

I need to rollback a specific table as I forgot to mention foreign key. and I dont want my data loss from all tables.

我的框架是Laravel 5.4

My framework is Laravel 5.4

先谢谢大家

推荐答案

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

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

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

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

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