Laravel migrations table not found
Asked Answered
C

2

22

I'm trying to recover a project after a failed HDD. Lost the mysql information, so just have the project code.

I hoped to be able to put my database back together by using artisan migrate, but the error message tells me:

database.migrations doesn't exist

Is there actually a way I can use my Laravel code files and the command line to rebuilt my database like this?

Thanks for the help.

Cuboid answered 4/2, 2014 at 18:55 Comment(3)
I'm assuming you update your app/config/database.php file with the correct info?Southeastward
Yes. I've sorted it out now. I'll add the answer.Cuboid
Please share more details - what have you tried to debug the problem?Rockwell
C
60

The command I needed to run was:

php artisan migrate:install

(I actually had more problems than this because the mysql install was messed up to. I don't know if simply php artisan migrate on its own would have implied :install but I'm adding it as an answer anyway should anyone have similar issues)

Cuboid answered 4/2, 2014 at 19:36 Comment(3)
I know this was necessary in laravel 3, but I think in laravel 4 it will do this for you when you run artisan migrate.Southeastward
to run this for a specific database using php artisan migrate:install database=database did not work and I needed this for two databases besides the main database..Mussorgsky
Great! Work for me.Hardpressed
V
1

For me, the issue I had is that I would try to do php artisan migrate:install which did create the table, however as soon as I did the php artisan migrate without the install, it would drop the empty migration table and would be unable to create or move it up. To move past the impasse, I php artisan migrate --pretend to get the first table's create table SQL, then I then added the first migration manually: insert into migrations( migration, batch ) values ('2014_10_12_000000_create_users_table','1'); and then confirmed with php artisan migrate:status which showed that the first migration was successful.

$ php artisan migrate:status

  Migration name .................................................................................................................... Batch / Status
  2014_10_12_000000_create_users_table ..................................................................................................... [1] Ran
  2014_10_12_100000_create_password_reset_tokens_table ..................................................................................... Pending
  2019_08_19_000000_create_failed_jobs_table ............................................................................................... Pending
  2019_12_14_000001_create_personal_access_tokens_table .................................................................................... Pending

Then the normal migration will succeed!

Vitalis answered 21/1, 2024 at 21:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.