Merge pull request #23419 from prathamesh-sonpatki/fix-showing-of-deprecation-warning-for-legacy-migrations
Correctly show deprecation warning for incompatible migrations
This commit is contained in:
commit
d6db96663d
@ -102,7 +102,7 @@ class V4_2 < V5_0
|
||||
module Legacy
|
||||
include FourTwoShared
|
||||
|
||||
def run(*)
|
||||
def migrate(*)
|
||||
ActiveSupport::Deprecation.warn \
|
||||
"Directly inheriting from ActiveRecord::Migration is deprecated. " \
|
||||
"Please specify the Rails release the migration was written for:\n" \
|
||||
|
@ -21,7 +21,7 @@ def setup
|
||||
teardown do
|
||||
connection.drop_table :testings rescue nil
|
||||
ActiveRecord::Migration.verbose = @verbose_was
|
||||
ActiveRecord::SchemaMigration.delete_all
|
||||
ActiveRecord::SchemaMigration.delete_all rescue nil
|
||||
end
|
||||
|
||||
def test_migration_doesnt_remove_named_index
|
||||
@ -101,6 +101,18 @@ def migrate(x)
|
||||
assert connection.columns(:testings).find { |c| c.name == 'created_at' }.null
|
||||
assert connection.columns(:testings).find { |c| c.name == 'updated_at' }.null
|
||||
end
|
||||
|
||||
def test_legacy_migrations_get_deprecation_warning_when_run
|
||||
migration = Class.new(ActiveRecord::Migration) {
|
||||
def up
|
||||
add_column :testings, :baz, :string
|
||||
end
|
||||
}
|
||||
|
||||
assert_deprecated do
|
||||
migration.migrate :up
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user