Home > other >  Why laravel migrate:fresh takes a long time for 422 tables?
Why laravel migrate:fresh takes a long time for 422 tables?

Time:05-24

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

CodePudding user response:

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

  • Related