Skip to content

Instantly share code, notes, and snippets.

@jamiew
Created August 13, 2009 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiew/167296 to your computer and use it in GitHub Desktop.
Save jamiew/167296 to your computer and use it in GitHub Desktop.
desc "Raises an error if there are pending migrations"
task :abort_if_pending_migrations => :environment do
if defined? ActiveRecord
pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
if pending_migrations.any?
puts "You have #{pending_migrations.size} pending migrations:"
pending_migrations.each do |pending_migration|
puts ' %4d %s' % [pending_migration.version, pending_migration.name]
end
abort %{Run "rake db:migrate" to update your database then try again.}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment