Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ensure the schema checking is done in the dev connection
  • Loading branch information
tenderlove committed Apr 3, 2013
1 parent 29f973c commit 1c2ad03
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions activerecord/lib/active_record/railties/databases.rake
Expand Up @@ -167,6 +167,11 @@ db_namespace = namespace :db do

# desc "Raises an error if there are pending migrations"
task :abort_if_pending_migrations => [:environment, :load_config] do
env = Rails.env
ActiveRecord::SchemaMigration.class_eval do
establish_connection 'development'
end

pending_migrations = ActiveRecord::Migrator.open(ActiveRecord::Migrator.migrations_paths).pending_migrations

if pending_migrations.any?
Expand All @@ -176,6 +181,9 @@ db_namespace = namespace :db do
end
abort %{Run `rake db:migrate` to update your database then try again.}
end
ActiveRecord::SchemaMigration.class_eval do
establish_connection env
end
end

desc 'Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)'
Expand Down

0 comments on commit 1c2ad03

Please sign in to comment.