Skip to content

Instantly share code, notes, and snippets.

@kv109
Created June 29, 2016 08:11
Show Gist options
  • Save kv109/5e9bf8d9fab7c9220a8e023631aaeb09 to your computer and use it in GitHub Desktop.
Save kv109/5e9bf8d9fab7c9220a8e023631aaeb09 to your computer and use it in GitHub Desktop.
Check for pending migrations on Heroku. Useful after a deploy.
# git_remote_name: git remote name associated with your heroku repository (usually "heroku")
def pending_migrations?(git_remote_name)
command = "heroku run rails runner \"puts ActiveRecord::Migrator.needs_migration?\" --remote #{git_remote_name}"
output = `#{command}`
output_last_line = output.split("\n").last
raise 'Could not check migration status' unless output_last_line.in? %w(true false)
output_last_line == 'true'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment