Skip to content
Permalink
Browse files
Deprecate passing migrations_paths to `connection.assume_migrated_u…
…pto_version`

Since #31727, `migrations_paths` in `assume_migrated_upto_version` is no
longer used.
  • Loading branch information
kamipo committed Dec 28, 2018
1 parent 9ed7c7e commit c1b14aded27e063ead32fa911aa53163d7cfc21a
@@ -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
@@ -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 @@ def internal_string_options_for_primary_key # :nodoc:
{ 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)

@@ -51,20 +51,11 @@ def define(info, &block) # :nodoc:

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
@@ -71,6 +71,13 @@ def setup
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"

0 comments on commit c1b14ad

Please sign in to comment.