diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-28 09:21:09 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-28 09:21:09 +0900 |
commit | c1b14aded27e063ead32fa911aa53163d7cfc21a (patch) | |
tree | e3bf69424a0c05278b1745c2a1000db98247f388 /activerecord | |
parent | 9ed7c7e9e2d61d60bc40aed421444cddc40d51f8 (diff) | |
download | rails-c1b14aded27e063ead32fa911aa53163d7cfc21a.tar.gz rails-c1b14aded27e063ead32fa911aa53163d7cfc21a.tar.bz2 rails-c1b14aded27e063ead32fa911aa53163d7cfc21a.zip |
Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`
Since #31727, `migrations_paths` in `assume_migrated_upto_version` is no
longer used.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/schema.rb | 11 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 7 |
4 files changed, 20 insertions, 12 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 1aa756cc7e..ca072be5e1 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`. + + *Ryuta Kamizono* + * MySQL: `ROW_FORMAT=DYNAMIC` create table option by default. Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 38cfc3a241..f9ec343156 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -2,6 +2,7 @@ require "active_record/migration/join_table" require "active_support/core_ext/string/access" +require "active_support/deprecation" require "digest/sha2" module ActiveRecord @@ -1050,8 +1051,13 @@ module ActiveRecord { primary_key: true } end - def assume_migrated_upto_version(version, migrations_paths) - migrations_paths = Array(migrations_paths) + def assume_migrated_upto_version(version, migrations_paths = nil) + unless migrations_paths.nil? + ActiveSupport::Deprecation.warn(<<~MSG) + Passing migrations_paths to #assume_migrated_upto_version is deprecated and will be removed in Rails 6.1. + MSG + end + version = version.to_i sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name) diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb index 216359867c..76bf53387d 100644 --- a/activerecord/lib/active_record/schema.rb +++ b/activerecord/lib/active_record/schema.rb @@ -51,20 +51,11 @@ module ActiveRecord if info[:version].present? ActiveRecord::SchemaMigration.create_table - connection.assume_migrated_upto_version(info[:version], migrations_paths) + connection.assume_migrated_upto_version(info[:version]) end ActiveRecord::InternalMetadata.create_table ActiveRecord::InternalMetadata[:environment] = connection.migration_context.current_environment end - - private - # Returns the migrations paths. - # - # ActiveRecord::Schema.new.migrations_paths - # # => ["db/migrate"] # Rails migration path by default. - def migrations_paths - ActiveRecord::Migrator.migrations_paths - end end end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index c6f4d4bf22..a38a853d4f 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -71,6 +71,13 @@ class MigrationTest < ActiveRecord::TestCase ActiveRecord::Migration.verbose = @verbose_was end + def test_passing_migrations_paths_to_assume_migrated_upto_version_is_deprecated + ActiveRecord::SchemaMigration.create_table + assert_deprecated do + ActiveRecord::Base.connection.assume_migrated_upto_version(0, []) + end + end + def test_migrator_migrations_path_is_deprecated assert_deprecated do ActiveRecord::Migrator.migrations_path = "/whatever" |