1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix migrations when migrating to a specified version number with a fresh database [#1 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
Ian White 2008-04-17 13:43:47 -05:00 committed by Joshua Peek
parent 9e1d506a8c
commit 82b4faf812
2 changed files with 12 additions and 3 deletions

View file

@ -364,8 +364,10 @@ module ActiveRecord
end end
def current_version def current_version
Base.connection.select_values( version = Base.connection.select_values(
"SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).max || 0 "SELECT version FROM #{schema_migrations_table_name}"
).map(&:to_i).max rescue nil
version || 0
end end
def proper_table_name(name) def proper_table_name(name)

View file

@ -813,6 +813,13 @@ if ActiveRecord::Base.connection.supports_migrations?
end end
end end
def test_migrator_db_has_no_schema_migrations_table
ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations;")
assert_nothing_raised do
ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1)
end
end
def test_migrator_verbosity def test_migrator_verbosity
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
assert PeopleHaveLastNames.message_count > 0 assert PeopleHaveLastNames.message_count > 0