Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails run specific migration [duplicate]

I've deleted a table in the database, call it X. db:migrate no longer works. I have a migration file called CreateX. Is there a way to run just that specific migration?

like image 524
Daniel Avatar asked Aug 22 '09 19:08

Daniel


People also ask

How do I run a particular migration in Rails?

To run a specific migration up or down, use db:migrate:up or db:migrate:down . The version number in the above commands is the numeric prefix in the migration's filename. For example, to migrate to the migration 20160515085959_add_name_to_users. rb , you would use 20160515085959 as the version number.

How do I rollback a specific migration in Rails?

i found these steps most useful. To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one.

How do I run a database migration in Ruby on Rails?

Rails Migration allows you to use Ruby to define changes to your database schema, making it possible to use a version control system to keep things synchronized with the actual code. Teams of developers − If one person makes a schema change, the other developers just need to update, and run "rake migrate".


1 Answers

rake db:migrate:redo VERSION=my_version 

Or you can go up or down from a specific version:

db:migrate:up VERSION=my_version db:migrate:down VERSION=my_version 
like image 97
JP Silvashy Avatar answered Oct 14 '22 00:10

JP Silvashy