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:
Matthew Draper 2016-02-23 14:59:13 +10:30
commit d6db96663d
2 changed files with 14 additions and 2 deletions

@ -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