Is there an easy way to run a single migration? I don't want to migrate to a certain version I just want to run a specific one.
Ruby-on-rails – Run a single migration file
migrationrubyruby-on-rails
Related Topic
- Ruby-on-rails – Rails: How to rename a database column in a Ruby on Rails migration
- Ruby-on-rails – How to rollback a specific migration
- Ruby-on-rails – Rails DB Migration – How To Drop a Table
- Backwards migration with Django South
- Ruby-on-rails – Difference between rake db:migrate db:reset and db:schema:load
- Laravel – Running one specific Laravel migration (single file)
- C# – Entity Framework rollback and remove bad migration
Best Answer
Assuming fairly recent version of Rails you can always run:
Where version is the timestamp in the filename of the migration.
Edit: At some point over the last 8 years (I'm not sure what version) Rails added checks that prevent this from running if it has already been run. This is indicated by an entry in the
schema_migrations
table. To re-run it, simply executerake db:migrate:redo VERSION=20090408054532
instead.