Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rollback a specific migration in laravel5

I need to rollback a specific table as I forgot to mention foreign key. and I dont want my data loss from all tables.

My framework is Laravel 5.4

Thanks in Advance Everyone

like image 853
Mansoor Ahmad Khan Avatar asked Dec 05 '22 14:12

Mansoor Ahmad Khan


2 Answers

I do it this way:

  1. Deleting a table manually;
  2. Going to "migrations" table and deleting corresponding row to your migration;
  3. php artisan migrate;
  4. done

For example, if you modified migration called "Settings", then you delete this table from DB and migrations table, then rerun artisan command.

like image 170
Alexander Kim Avatar answered Dec 08 '22 04:12

Alexander Kim


You can do

php artisan migrate:rollback --path=/database/migrations/your_file.php

like image 44
Hajopa Avatar answered Dec 08 '22 04:12

Hajopa