-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should not restart if migrate does nothing #5
Labels
Comments
+1 |
+1 on this too. |
+1 |
+1 I wrote a rake task that we use as part of our build process to put our app in maintenance mode only if there are pending migrations, but it would be nice to leverage this to not even run the migrate & restart steps from heroku_san if there are no pending migrations. Here's the rake task: task :heroku_pending_migrations, [:app] => :environment do |t, args|
# returns an array of the schema_migrations run on heroku app +app_name+
def get_remote_migrations(app_name)
connection_string = `heroku pg:credentials DATABASE_URL --app #{app_name} | head -2 | tail -1`.strip
`psql #{connection_string} -Atc "SELECT * FROM schema_migrations;"`.split
end
app_name = args[:app]
remote_migrations = get_remote_migrations(app_name)
local_migrations = ActiveRecord::Migrator.new(:up, ActiveRecord::Migrator.migrations_paths).migrations
pending_migrations = local_migrations.reject { |m| remote_migrations.include?(m.version.to_s) }
if pending_migrations.present?
puts 'Pending migrations:'
puts pending_migrations.map &:version
exit false
else
puts 'No pending migrations'
exit true
end
end |
+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: