提交 a49de981 编写于 作者: J Josh Susser

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!
上级 b07c2c0f
......@@ -464,7 +464,7 @@ def assume_migrated_upto_version(version, migrations_path = ActiveRecord::Migrat
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 @@ def assume_migrated_upto_version(version, migrations_path = ActiveRecord::Migrat
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
......
......@@ -55,7 +55,7 @@ def self.define(info={}, &block)
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)
......
......@@ -47,8 +47,9 @@ def setup
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册