Run heroku migrations on each deploy by piggybacking on assets:precompile

A simple solution to an annoying problem!

# Rakefile
task "assets:precompile" => "db:migrate" if ENV['MIGRATE_ON_PRECOMPILE']

# run to enable
heroku config:set MIGRATE_ON_PRECOMPILE=1

2 thoughts on “Run heroku migrations on each deploy by piggybacking on assets:precompile

  1. Did you also try the following? It adds a dependency between the tasks, if you the ENV var is set. Might be cleaner than starting a new command.

    # Rakefile
    if ENV[‘MIGRATE_ON_PRECOMPILE’]
    task “assets:precompile” => “rake db:migrate”
    end

Leave a comment