Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php Artisan migrate is super Slow?

Tags:

php

laravel

I am new to Laravel, I am using the 5.7 version, I am following a course that looks very good but I created my database on mysql and then I tried to run the command - php artisan migrate - and it took so long, I get bored everytime and I cancel it, there must be a better solution because it is very very slow, the man I am following his course get a response quickly as do many others, is there any solution out there that can help me move faster, am I missing something ?

Any help would be much appreciated.

like image 936
TaouBen Avatar asked Oct 27 '18 22:10

TaouBen


Video Answer


2 Answers

A lot of depends on your migrations but also on your server. Assuming you are using localhost server speed shouldn't affect, so you should take a look at migrations.

Again, assuming you just create new tables migrations should be quick, but when you alter schema or add some data in loops or run some queries then yes, they might be slow if you don't have optimized code but this is reason of code itself and not in general migrations.

like image 162
Marcin Nabiałek Avatar answered Oct 22 '22 00:10

Marcin Nabiałek


This must most likely be a peculiar problem on your server. Quickly restart your server and try again. If it persists, go on to restart your PC.

Laravel migrations are usually very fast, even when very bulky. So if this problem persists even after restarting your server and even the PC, then you will have to conduct a quick investigation to know what the cause is.

Comment out all the lines of code in the create method's callback. Then try running the migration. This should be fast. Go on to add the commented lines one after the other why testing, you should see which line of code is slowing you.

like image 34
Elisha Senoo Avatar answered Oct 22 '22 02:10

Elisha Senoo