Skip to content

Commit d6db966

Browse files
committed
Merge pull request rails#23419 from prathamesh-sonpatki/fix-showing-of-deprecation-warning-for-legacy-migrations
Correctly show deprecation warning for incompatible migrations
2 parents 37f32c0 + 33b0dbe commit d6db966

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

activerecord/lib/active_record/migration/compatibility.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class V4_2 < V5_0
102102
module Legacy
103103
include FourTwoShared
104104

105-
def run(*)
105+
def migrate(*)
106106
ActiveSupport::Deprecation.warn \
107107
"Directly inheriting from ActiveRecord::Migration is deprecated. " \
108108
"Please specify the Rails release the migration was written for:\n" \

activerecord/test/cases/migration/compatibility_test.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setup
2121
teardown do
2222
connection.drop_table :testings rescue nil
2323
ActiveRecord::Migration.verbose = @verbose_was
24-
ActiveRecord::SchemaMigration.delete_all
24+
ActiveRecord::SchemaMigration.delete_all rescue nil
2525
end
2626

2727
def test_migration_doesnt_remove_named_index
@@ -101,6 +101,18 @@ def migrate(x)
101101
assert connection.columns(:testings).find { |c| c.name == 'created_at' }.null
102102
assert connection.columns(:testings).find { |c| c.name == 'updated_at' }.null
103103
end
104+
105+
def test_legacy_migrations_get_deprecation_warning_when_run
106+
migration = Class.new(ActiveRecord::Migration) {
107+
def up
108+
add_column :testings, :baz, :string
109+
end
110+
}
111+
112+
assert_deprecated do
113+
migration.migrate :up
114+
end
115+
end
104116
end
105117
end
106118
end

0 commit comments

Comments
 (0)