Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i rollback on ruby on rails in my situation

I need to rollback migration on my ruby on rails project

I accidently deleted my migration file, [ID:20180214033313].

my migration status

migration output

I tried doing bundle exec rake:db rollback but it didn't help and I also tried bundle exec rake db:migrate:down VERSION=20180214033313 but it gave me the error below,

ActiveRecord::UnknownMigrationVersionError: 
No migration with version number 20180214033313> 

Any suggestions on how can I fix this?

like image 949
Menphis Avatar asked Oct 16 '25 18:10

Menphis


1 Answers

Aaah, today I was confronted with this same problem following the deletion of a migration. which is probably your case...

To reinstall existing migrations, do a migration reset:

rails db:migrate:reset

And to have a good knowledge about migrations, my little 12 points guide:

  • db:migrate runs (single) migrations that have not run yet.

  • db:create creates the database

  • db:drop deletes the database

  • db:schema:load creates tables and columns within the existing database following schema.rb. This will delete existing data.

  • db:setup does db:create, db:schema:load, db:seed

  • db:reset does db:drop, db:setup

  • db:migrate:reset does db:drop, db:create, db:migrate

  • db:migrate:redo runs (db:migrate:down db:migrate:up) or (db:rollback db:migrate) depending on the specified migration

  • db:schema:dump dumps the current env's schema (and seems to create the db as well)

  • db:forward advances the current schema version to the next one

  • db:seed (only) runs the db/seed.rb file

  • db:migrate:down rolls back one specific migration

like image 88
kamate vakaramoko Avatar answered Oct 18 '25 10:10

kamate vakaramoko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!