diff options
author | Josh Susser <josh@hasmanythrough.com> | 2010-03-16 23:02:03 -0700 |
---|---|---|
committer | Josh Susser <josh@hasmanythrough.com> | 2010-12-01 10:46:29 -0800 |
commit | 4e4e9ad48a222ac94a904c62ae684c609bd8e177 (patch) | |
tree | 6b2fac055d22c90d22ef2063c0625b7c6082d255 /activerecord/lib/active_record/migration.rb | |
parent | c283cdd63cafdb04784cfcc5094da41c9268c20c (diff) | |
download | rails-4e4e9ad48a222ac94a904c62ae684c609bd8e177.tar.gz rails-4e4e9ad48a222ac94a904c62ae684c609bd8e177.tar.bz2 rails-4e4e9ad48a222ac94a904c62ae684c609bd8e177.zip |
record migration timestamp when migrations run
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index f6321f1499..2cf2f4acd0 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -628,7 +628,7 @@ module ActiveRecord raise UnknownMigrationVersionError.new(@target_version) if target.nil? unless (up? && migrated.include?(target.version.to_i)) || (down? && !migrated.include?(target.version.to_i)) target.migrate(@direction) - record_version_state_after_migrating(target.version) + record_version_state_after_migrating(target) end end @@ -664,7 +664,7 @@ module ActiveRecord begin ddl_transaction do migration.migrate(@direction) - record_version_state_after_migrating(migration.version) + record_version_state_after_migrating(migration) end rescue => e canceled_msg = Base.connection.supports_ddl_transactions? ? "this and " : "" @@ -690,16 +690,19 @@ module ActiveRecord end private - def record_version_state_after_migrating(version) + def record_version_state_after_migrating(target) table = Arel::Table.new(self.class.schema_migrations_table_name) @migrated_versions ||= [] if down? - @migrated_versions.delete(version) - table.where(table["version"].eq(version.to_s)).delete + @migrated_versions.delete(target.version) + table.where(table["version"].eq(target.version.to_s)).delete else - @migrated_versions.push(version).sort! - table.insert table["version"] => version.to_s + @migrated_versions.push(target.version).sort! + table.insert( + table["version"] => target.version.to_s, + table["migrated_at"] => Time.now + ) end end |