From 7fc4979d4dab63591dcbf75367c496cbfa2881ce Mon Sep 17 00:00:00 2001 From: yui-knk Date: Mon, 28 Mar 2016 00:49:43 +0900 Subject: Migrations: move version-finding responsibility `ActiveRecord::Migration` needn't know about migration version compatibility lookup. Delegate it to the Compatibility module. Signed-off-by: Jeremy Daer --- activerecord/lib/active_record/migration.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'activerecord/lib/active_record/migration.rb') diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 99a79024ad..33c236a732 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -524,13 +524,7 @@ module ActiveRecord end def self.[](version) - version = version.to_s - name = "V#{version.tr('.', '_')}" - unless Compatibility.const_defined?(name) - versions = Compatibility.constants.grep(/\AV[0-9_]+\z/).map { |s| s.to_s.delete('V').tr('_', '.').inspect } - raise ArgumentError, "Unknown migration version #{version.inspect}; expected one of #{versions.sort.join(', ')}" - end - Compatibility.const_get(name) + Compatibility.find(version) end def self.current_version -- cgit v1.2.3 From 76f7da0c6516bed5d1375b5d55dde71ba71df4f7 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Fri, 29 Apr 2016 23:15:30 -0400 Subject: Replace `Rails.version.to_f` with Active Record Rails should not be explicity mentioned within Active Record, since railties and the Rails ecosystem is not required for use. --- activerecord/lib/active_record/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/migration.rb') diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 33c236a732..5dc7020944 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -528,7 +528,7 @@ module ActiveRecord end def self.current_version - Rails.version.to_f + ActiveRecord::VERSION::STRING.to_f end MigrationFilenameRegexp = /\A([0-9]+)_([_a-z0-9]*)\.?([_a-z0-9]*)?\.rb\z/ # :nodoc: -- cgit v1.2.3 From 2687a5e0ab1d5761add7d14ac750343dc473d8fb Mon Sep 17 00:00:00 2001 From: Erol Fornoles Date: Tue, 3 May 2016 19:55:08 +0800 Subject: Fix small typo in Active Record Migrations documentation [ci skip] --- activerecord/lib/active_record/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/migration.rb') diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 5dc7020944..f30861b4d0 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -277,7 +277,7 @@ module ActiveRecord # * change_column(table_name, column_name, type, options): Changes # the column to a different type using the same parameters as add_column. # * change_column_default(table_name, column_name, default): Sets a - # default value for +column_name+ definded by +default+ on +table_name+. + # default value for +column_name+ defined by +default+ on +table_name+. # * change_column_null(table_name, column_name, null, default = nil): # Sets or removes a +NOT NULL+ constraint on +column_name+. The +null+ flag # indicates whether the value can be +NULL+. See -- cgit v1.2.3 From 238c77dedf3a9de27f8e902ad3dcfdc3480d95bc Mon Sep 17 00:00:00 2001 From: Kang-Kyu Lee Date: Thu, 12 May 2016 20:56:55 -0700 Subject: Add missing space and newline for clarity --- activerecord/lib/active_record/migration.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/migration.rb') diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index f30861b4d0..81fe053fe1 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -166,13 +166,13 @@ module ActiveRecord class EnvironmentMismatchError < ActiveRecordError 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 << "You are running in `#{ current }` environment. " msg << "If you are sure you want to continue, first set the environment using:\n\n" msg << "\tbin/rails db:environment:set" if defined?(Rails.env) - super("#{msg} RAILS_ENV=#{::Rails.env}") + super("#{msg} RAILS_ENV=#{::Rails.env}\n\n") else - super(msg) + super("#{msg}\n\n") end end end -- cgit v1.2.3