From a49de9811ab4cf39fbdb5a6941ee003b1e489184 Mon Sep 17 00:00:00 2001 From: Josh Susser Date: Wed, 1 Dec 2010 11:56:21 -0800 Subject: tests mostly pass adjust to work with instance-based migations migrated_at can't be null why must people have last names? it's killing me! --- .../active_record/connection_adapters/abstract/schema_statements.rb | 4 ++-- activerecord/lib/active_record/schema.rb | 2 +- activerecord/test/cases/ar_schema_test.rb | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index ccb6fe3be2..de7d358df9 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -464,7 +464,7 @@ module ActiveRecord end unless migrated.include?(version) - execute "INSERT INTO #{sm_table} (version) VALUES ('#{version}')" + execute "INSERT INTO #{sm_table} (version,migrated_at) VALUES ('#{version}','#{Time.now.to_s(:db)}')" end inserted = Set.new @@ -472,7 +472,7 @@ module ActiveRecord if inserted.include?(v) raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict." elsif v < version - execute "INSERT INTO #{sm_table} (version) VALUES ('#{v}')" + execute "INSERT INTO #{sm_table} (version,migrated_at) VALUES ('#{v}','#{Time.now.to_s(:db)}')" inserted << v end end diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb index 4b846f2e27..9a47fd3b84 100644 --- a/activerecord/lib/active_record/schema.rb +++ b/activerecord/lib/active_record/schema.rb @@ -55,7 +55,7 @@ module ActiveRecord assume_migrated_upto_version(info[:version], schema.migrations_path) unless info[:version].blank? end - def self.migration(version, name="", options={}) + def migration(version, name="", options={}) name, options = "", name if name.is_a?(Hash) table = Arel::Table.new(ActiveRecord::Migrator.schema_migrations_table_name) diff --git a/activerecord/test/cases/ar_schema_test.rb b/activerecord/test/cases/ar_schema_test.rb index 930a57330d..28f219e213 100644 --- a/activerecord/test/cases/ar_schema_test.rb +++ b/activerecord/test/cases/ar_schema_test.rb @@ -47,8 +47,9 @@ if ActiveRecord::Base.connection.supports_migrations? end def test_migration_adds_row_to_migrations_table - ActiveRecord::Schema.migration("123001") - ActiveRecord::Schema.migration("123002", "add_magic_power_to_unicorns") + schema = ActiveRecord::Schema.new + schema.migration("123001") + schema.migration("123002", "add_magic_power_to_unicorns") rows = @connection.select_all("SELECT * FROM #{@connection.quote_table_name(@sm_table)}") assert_equal 2, rows.length -- cgit v1.2.3