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
Advertisements

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s