Laravel更改迁移顺序 [英] Laravel change migration order

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

问题描述

有没有一种方法可以更改迁移顺序而不重新构建迁移顺序?因为现在我的外键-_-(使用laravel)有问题

Is there a way how I can change the migrations order without remaking them all? Because now I have a problem with my foreign keys -_- (working with laravel)

推荐答案

  1. 回滚所有迁移(或从新的数据库开始);

  1. Roll back all the migrations (or start with a fresh database);

更改构成迁移文件名第一部分的日期,以便它们按您想要的顺序排列(例如,对于2014_06_24_134109_update_database.php,日期和时间为2014-06-24,13:41 :09);

Change the dates that form the first part of the migration filenames so they're in the order you want (eg. for 2014_06_24_134109_update_database.php, the date & time is 2014-06-24, 13:41:09);

再次运行迁移.

关于您对外键的评论...我不确定问题出在Laravel.更有可能的是MySQL.

With respect to your comment about foreign keys... I'm not sure that the problem is with Laravel. More likely, it's just MySQL.

我避免使用外键,因为一旦获得了一组相当复杂的关系,就开始遇到数据库一致性问题,就像您看到的那样-服务器很难弄清楚创建表和目录的顺序.关系,并且开始在转储文件(用于备份)之类的事情上引起麻烦.

I avoid foreign keys because once you get a moderately complicated set of relations, you start to run into problems with database consistency like you're seeing - it's hard for the server to figure out what order to create the tables & relationships in, and it starts to cause difficulties with things like dump files (for backups).

这篇关于Laravel更改迁移顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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