diff options
author | Matthew Draper <matthew@trebex.net> | 2016-02-23 14:59:13 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-02-23 14:59:13 +1030 |
commit | d6db96663de1a83f2d57076fdb3f7170071b085b (patch) | |
tree | 9bd02d81f299b5eebf9b95194c7dbc82ea75d6ec /activerecord | |
parent | 37f32c013e010f504ec9d6caebc4a8aeb49af9b5 (diff) | |
parent | 33b0dbe40729ba130c3c83391a3d9581c2a8b034 (diff) | |
download | rails-d6db96663de1a83f2d57076fdb3f7170071b085b.tar.gz rails-d6db96663de1a83f2d57076fdb3f7170071b085b.tar.bz2 rails-d6db96663de1a83f2d57076fdb3f7170071b085b.zip |
Merge pull request #23419 from prathamesh-sonpatki/fix-showing-of-deprecation-warning-for-legacy-migrations
Correctly show deprecation warning for incompatible migrations
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/migration/compatibility.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration/compatibility_test.rb | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/migration/compatibility.rb b/activerecord/lib/active_record/migration/compatibility.rb index 45e35a4f71..09d55adcd7 100644 --- a/activerecord/lib/active_record/migration/compatibility.rb +++ b/activerecord/lib/active_record/migration/compatibility.rb @@ -102,7 +102,7 @@ module ActiveRecord 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" \ diff --git a/activerecord/test/cases/migration/compatibility_test.rb b/activerecord/test/cases/migration/compatibility_test.rb index 6d5b6243db..60ca90464d 100644 --- a/activerecord/test/cases/migration/compatibility_test.rb +++ b/activerecord/test/cases/migration/compatibility_test.rb @@ -21,7 +21,7 @@ module ActiveRecord 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 @@ module ActiveRecord 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 |