I only want to undo one migration file, something like
rake db:rollback VERSION=$TIMESTAMP
This command doesn't work. Any suggestion?
The part with migrate:rollback is the actual command. It says that you want to rollback certain database migrations. The last part, --step=1 , is a parameter for the migrate:rollback command. By default, php artisan migrate:rollback will rollback all of your database migrations.
If you want to rollback a specific migration, look in your migrations table, you'll see each migration table has its own batch number. So, when you roll back, each migration that was part of the last batch gets rolled back.
To undo a rails generate command, run a rails destroy command. You can then edit the file and run rake db:migrate again. (See how to roll back a Migration file to rollback a specific migration or multiple migrations.)
If you have already run the migration then you cannot just edit the migration and run the migration again: Rails thinks it has already run the migration and so will do nothing when you run rake db:migrate.
rake db:migrate:down VERSION=$TIMESTAMP
should do the trick.
rake db:rollback is now the way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With