I have run the following Laravel command PHP artisan make: migration add_category_id_to_posts
but I need to run the following command as well PHP artisan make: migration add_category_id_to_posts --table=posts
then I need to roll back the first command and run the second command. then How?
Asked
Active
Viewed 2,527 times
1

Abdelrahman Shahin
- 126
- 1
- 8

Okurawa
- 23
- 2
- 9
-
You can't roll back such commands. Just go ahead and delete migration file which is created. – fatm Sep 14 '21 at 09:56
-
Does this answer your question? [Rollback one specific migration in Laravel](https://stackoverflow.com/questions/30287896/rollback-one-specific-migration-in-laravel) – NKSM Sep 14 '21 at 20:50
3 Answers
1
As mentioned by Fatima Mazhit, this command cannot be rolled back.
Simply delete the newly created add_category_id_to_posts
migration file and run php artisan make:migration add_category_id_to_posts --table=posts
.

Simon
- 63
- 1
- 11
1
You need to delete the earlier created migration manually and run the same command again after making appropriate changes in your migration. Or simply run php artisan migrate:rollback
, will do your task.

Daljit Singh
- 270
- 3
- 10
0
go to your database/migration/your migration delete the migration you recently created, and then run the command again like so:
php artisan make:migration add_category_id_to_posts --table=posts.
note: you can rollback your migrations if you migrate your migrations on the command : php artisan migrate
then you can rollback by php artisan migrate:rollback