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?
Asked
Active
Viewed 5.2k times
72
-
2The question is a duplicate. The answer here is better. – ConnorWGarvey Dec 01 '15 at 21:03
1 Answers
177
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

JP Silvashy
- 46,977
- 48
- 149
- 227
-
1rake db:migrate:redo seems to work for me (db:specific:redo just gives an error, I'm imagining a version issue) – Daniel Aug 22 '09 at 20:01
-
Oops yah, you were right, that was my custom rake task mixed in, but I fixed it those should work well now. – JP Silvashy Aug 22 '09 at 20:03
-
38N.B. If the table has been dropped from the database, `rake db:migrate:up VERSION=my_version` may do _nothing_, because the schema_migrations table still says it is done. In the same situation `rake db:migrate:redo VERSION=my_version` may _fail_ because it cannot drop the table. In this case, comment out the `down` method in the migration temporarily and re-run `rake db:migrate:redo...` – Leo Sep 08 '12 at 11:54