Using Rails initializers for running migrations when deploying applications
In some cases it is difficult to run migrations from the irb console using the cf console command. It is possible to include your migration execution within a rails initializer when your application starts.
To follow this approach you have to create a new initializer file within the config/initializers directory. Let's call it run_migrations.rb.
The file should contain the following line of code for executing the database migrations:
ActiveRecord::Migrator.migrate(Rails.root.join("db/migrate"), nil)
And that's it. Next time migrations will be run automatically when you execute cf push for deploying your application to anynines.
0
Please sign in to leave a comment.
Comments
0 comments