diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-03 16:23:07 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-03 16:23:07 -0700 |
commit | 341e71a1b9a3d0ad367f79ff89b1c97fe6890905 (patch) | |
tree | 3ad9186bc537b3752a8f6f7f3e51e4a4d2e872a5 | |
parent | 8beda11fd3cbd2db21a7a7a7ae9823edbbc2dd5e (diff) | |
download | rails-341e71a1b9a3d0ad367f79ff89b1c97fe6890905.tar.gz rails-341e71a1b9a3d0ad367f79ff89b1c97fe6890905.tar.bz2 rails-341e71a1b9a3d0ad367f79ff89b1c97fe6890905.zip |
dry up some migration logic
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index b075632de6..6744a0783a 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -584,11 +584,13 @@ module ActiveRecord runnable.each do |migration| Base.logger.info "Migrating to #{migration.name} (#{migration.version})" if Base.logger + seen = migrated.include?(migration.version.to_i) + # On our way up, we skip migrating the ones we've already migrated - next if up? && migrated.include?(migration.version.to_i) + next if up? && seen # On our way down, we skip reverting the ones we've never migrated - if down? && !migrated.include?(migration.version.to_i) + if down? && !seen migration.announce 'never migrated, skipping'; migration.write next end |