为什么Laravel迁移:新鲜需要很长时间才能花422张桌子?

发布于 2025-01-31 10:56:10 字数 565 浏览 2 评论 0原文

我有一个Laravel项目,每次我想创建一个新项目时,

php artisan migrate:fresh

它都可以正常运行,但是经过3年的工作,我已经到达了422个表,现在我想开始迁移至少需要将近5到10分钟才能完成迁移工作。

我可以在localhost中毫无问题地等待,但是我最大的问题是当我使用 > LaravelInstaller 库为项目添加一个安装程序。

它需要很长时间,最终返回下一个错误

内部服务器错误500

因此,为了使此安装在如此长的持续时间内工作,我必须在php.ini中更改最大时间限制以解决此问题。

有什么办法可以加快迁移的速度?

谢谢

I have a Laravel project and I'm using this command to migrate a database every time I want to create a new project

php artisan migrate:fresh

It was working fine, but after 3 years of working on it I've reached 422 tables and now when I want to migrate it takes almost 5 to 10 minutes at least to complete a migrate job.

I can wait without problems in localhost, but my biggest problem is when I use the LaravelInstaller library to add an installer feature to the project.

It takes a long time and eventually it returns the next error

internal server error 500

So in order to make this installation work with such long durations, I have to change Max time limit in php.ini to solve this issue.

Is there any way to speed up the migration?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就像说晚安 2025-02-07 10:56:10

这是对加速问题的答案,而不是内部服务器错误500,因为没有与引起该错误的问题有关的任何详细信息。

我假设您至少使用Laravel 8,基于您可以尝试schema dump,它添加到创建当前架构的转储中。

这是命令:

php artisan schema:dump

# Below command is taken from below link, in case of more help, don't hesitate 
# to read the docs
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune

您有一个问题仅仅是因为您已经创建了大量的迁移文件列表,在这种情况下,通常,进行迁移:新鲜不应该花太多时间,即使对于422 < /code>表,但是您遇到了这个问题,因为重复此过程并使列表在几年中更大。

这是参考的链接

This is an answer to speed-up issue, not internal server error 500, because there's not any details related to issue that causing that error.

I'm assuming you're using Laravel 8 at least, and base on that you can try Schema Dump, which It's added to creates a dump of the current schema.

Here's the command :

php artisan schema:dump

# Below command is taken from below link, in case of more help, don't hesitate 
# to read the docs
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune

You have this issue simply because you've a huge list of migration files that were created, and in this case, in general, doing a migration:fresh should not take so much time, even for 422 table, but you have this issues, because of repeating this process and make list bigger in years.

Here's the link to reference

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文