DEV Community

Michel Sánchez Montells
Michel Sánchez Montells

Posted on

Run a specific migration

Sometimes we search how to do something. We find out the correct answer, we use the tip and we forget how to do it again because this situation is not frequent at all.

This entry is just for having my own memory and easy search something that I am sure will be removed from my brain soon.

There is not common but can happen that you need to run an specific migration and don't want to run the subsequent migrations.

Let's go:

require "{Rails.root.to_s}/db/migrate/20090408054532_add_foos.rb""
Enter fullscreen mode Exit fullscreen mode

In details...

Identify the migration


  • Open console

rails c

  • Require the migration

require "#{Rails.root.to_s}/db/migrate/20090408054532_add_foos.rb"

  • Run the migration

DONE ;-)


Top comments (0)