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

查看:42
本文介绍了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天全站免登陆