diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-02-25 19:32:50 +0200 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-04-19 23:37:58 +0300 |
commit | bb9d6eb094f29bb94ef1f26aa44f145f17b973fe (patch) | |
tree | bafe0fe871e0a1d2249c16f48f077b242c6c7426 /activerecord/lib/active_record | |
parent | b77d2aa0c336492ba33cbfade4964ba0eda3ef84 (diff) | |
download | rails-bb9d6eb094f29bb94ef1f26aa44f145f17b973fe.tar.gz rails-bb9d6eb094f29bb94ef1f26aa44f145f17b973fe.tar.bz2 rails-bb9d6eb094f29bb94ef1f26aa44f145f17b973fe.zip |
Add additional raise UnknownMigrationVersionError
Raise error on the movement of migrations
when the current migration does not exist.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 43b6a746e0..51c82f4ced 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -1105,6 +1105,10 @@ module ActiveRecord def move(direction, migrations_paths, steps) migrator = new(direction, migrations(migrations_paths)) + if current_version != 0 && !migrator.current_migration + raise UnknownMigrationVersionError.new(current_version) + end + start_index = if current_version == 0 0 @@ -1112,11 +1116,9 @@ module ActiveRecord migrator.migrations.index(migrator.current_migration) end - if start_index - finish = migrator.migrations[start_index + steps] - version = finish ? finish.version : 0 - send(direction, migrations_paths, version) - end + finish = migrator.migrations[start_index + steps] + version = finish ? finish.version : 0 + send(direction, migrations_paths, version) end end |