aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration.rb
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2016-01-08 11:53:25 -0600
committerschneems <richard.schneeman@gmail.com>2016-01-08 14:05:20 -0600
commitd70c68d76abcbc24ef0e56b7a7b580d0013255dd (patch)
tree4c3eef7f058ae7ea341814e8869f808b7a7ef67c /activerecord/lib/active_record/migration.rb
parentf6628adc11e2e57db75030fca9bae035be5cd95b (diff)
downloadrails-d70c68d76abcbc24ef0e56b7a7b580d0013255dd.tar.gz
rails-d70c68d76abcbc24ef0e56b7a7b580d0013255dd.tar.bz2
rails-d70c68d76abcbc24ef0e56b7a7b580d0013255dd.zip
Fixing tests and re-locating error checking.
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r--activerecord/lib/active_record/migration.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index e06a581094..f5753fe426 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -164,7 +164,7 @@ module ActiveRecord
end
class EnvironmentMismatchError < ActiveRecordError
- def initialize(current: , stored: )
+ def initialize(current: nil, stored: nil)
msg = "You are attempting to modify a database that was last run in #{ stored } environment.\n"
msg << "You are running in #{ current } environment."
msg << "if you are sure you want to continue, run the same command with the environment variable\n"
@@ -1238,7 +1238,12 @@ module ActiveRecord
end
def self.last_stored_environment
- ActiveRecord::InternalMetadata[:environment]
+ return nil if current_version == 0
+ raise NoEnvironmentInSchemaError unless ActiveRecord::InternalMetadata.table_exists?
+
+ environment = ActiveRecord::InternalMetadata[:environment]
+ raise NoEnvironmentInSchemaError unless environment
+ environment
end
def self.current_environment
@@ -1246,11 +1251,7 @@ module ActiveRecord
end
def self.protected_environment?
- return false if current_version == 0
- raise NoEnvironmentInSchemaError unless ActiveRecord::InternalMetadata.table_exists?
-
- raise NoEnvironmentInSchemaError unless last_stored_environment
- ActiveRecord::Base.protected_environments.include?(last_stored_environment)
+ ActiveRecord::Base.protected_environments.include?(last_stored_environment) if last_stored_environment
end
def up?