method
check_current_protected_environment!
v7.1.3.4 -
Show latest stable
- Class:
ActiveRecord::Tasks::DatabaseTasks
check_current_protected_environment!(db_config)private
No documentation available.
# File activerecord/lib/active_record/tasks/database_tasks.rb, line 604
def check_current_protected_environment!(db_config)
with_temporary_pool(db_config) do |pool|
connection = pool.connection
current = connection.migration_context.current_environment
stored = connection.migration_context.last_stored_environment
if connection.migration_context.protected_environment?
raise ActiveRecord::ProtectedEnvironmentError.new(stored)
end
if stored && stored != current
raise ActiveRecord::EnvironmentMismatchError.new(current: current, stored: stored)
end
rescue ActiveRecord::NoDatabaseError
end
end