Skip to content

Commit c1b14ad

Browse files
committed
Deprecate passing migrations_paths to connection.assume_migrated_upto_version
Since #31727, `migrations_paths` in `assume_migrated_upto_version` is no longer used.
1 parent 9ed7c7e commit c1b14ad

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

activerecord/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
2+
3+
*Ryuta Kamizono*
4+
15
* MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
26

37
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "active_record/migration/join_table"
44
require "active_support/core_ext/string/access"
5+
require "active_support/deprecation"
56
require "digest/sha2"
67

78
module ActiveRecord
@@ -1050,8 +1051,13 @@ def internal_string_options_for_primary_key # :nodoc:
10501051
{ primary_key: true }
10511052
end
10521053

1053-
def assume_migrated_upto_version(version, migrations_paths)
1054-
migrations_paths = Array(migrations_paths)
1054+
def assume_migrated_upto_version(version, migrations_paths = nil)
1055+
unless migrations_paths.nil?
1056+
ActiveSupport::Deprecation.warn(<<~MSG)
1057+
Passing migrations_paths to #assume_migrated_upto_version is deprecated and will be removed in Rails 6.1.
1058+
MSG
1059+
end
1060+
10551061
version = version.to_i
10561062
sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name)
10571063

activerecord/lib/active_record/schema.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,11 @@ def define(info, &block) # :nodoc:
5151

5252
if info[:version].present?
5353
ActiveRecord::SchemaMigration.create_table
54-
connection.assume_migrated_upto_version(info[:version], migrations_paths)
54+
connection.assume_migrated_upto_version(info[:version])
5555
end
5656

5757
ActiveRecord::InternalMetadata.create_table
5858
ActiveRecord::InternalMetadata[:environment] = connection.migration_context.current_environment
5959
end
60-
61-
private
62-
# Returns the migrations paths.
63-
#
64-
# ActiveRecord::Schema.new.migrations_paths
65-
# # => ["db/migrate"] # Rails migration path by default.
66-
def migrations_paths
67-
ActiveRecord::Migrator.migrations_paths
68-
end
6960
end
7061
end

activerecord/test/cases/migration_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ def setup
7171
ActiveRecord::Migration.verbose = @verbose_was
7272
end
7373

74+
def test_passing_migrations_paths_to_assume_migrated_upto_version_is_deprecated
75+
ActiveRecord::SchemaMigration.create_table
76+
assert_deprecated do
77+
ActiveRecord::Base.connection.assume_migrated_upto_version(0, [])
78+
end
79+
end
80+
7481
def test_migrator_migrations_path_is_deprecated
7582
assert_deprecated do
7683
ActiveRecord::Migrator.migrations_path = "/whatever"

0 commit comments

Comments
 (0)