2

How to rollback the single table in laravel 4. I ran php artisan migrate:rollback to roll back all the migrations but how to rollback the single table

Advice much appreciated

Rajat
  • 119
  • 2
  • 9
  • `php artisan migrate:rollback` rollbacks last migration and `:refresh` does all but there is no command for single specific one, AFAIK. – The Alpha Nov 28 '13 at 07:08
  • [You may check this answer](http://stackoverflow.com/questions/17697247/laravel-4-artisan-how-to-rollback-to-a-specific-migration-state). – The Alpha Nov 28 '13 at 07:09

3 Answers3

10

for example, you want to create the user table again, just go to mysql and delete from migration's table the field that correspond to TIMESTAMP_create_users_table:

DELETE FROM MIGRATIONS WHERE MIGRATION ="2014_10_12_000000_create_users_table";

and drop the users table too:

DROP TABLE users;

after that, just run

php artisan migrate

and that's it!

Andres Felipe
  • 4,292
  • 1
  • 24
  • 41
0

If you wish to rollback only a specific table, you should make a migration that only includes that table. It's really that simple. Making large migrations covering several updates doesn't make any sense.

Create migrations based upon their purpose. That means; on a live project every little code change should have its own related migration.

Ronald Hulshof
  • 1,986
  • 16
  • 22
0

Just run The command (Laravel 5):-

php artisan migrate:rollback --step=5

It will undo last 5 migrations (in fact it will execute the function "down" in each one)

php artisan migrate

It will add all migration table into database

Krolexer
  • 83
  • 4
HeadAndTail
  • 804
  • 8
  • 9