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:
parent
9e1d506a8c
commit
82b4faf812
2 changed files with 12 additions and 3 deletions
|
@ -364,8 +364,10 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def current_version
|
||||
Base.connection.select_values(
|
||||
"SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).max || 0
|
||||
version = Base.connection.select_values(
|
||||
"SELECT version FROM #{schema_migrations_table_name}"
|
||||
).map(&:to_i).max rescue nil
|
||||
version || 0
|
||||
end
|
||||
|
||||
def proper_table_name(name)
|
||||
|
|
|
@ -813,6 +813,13 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
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
|
||||
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1)
|
||||
assert PeopleHaveLastNames.message_count > 0
|
||||
|
@ -1010,7 +1017,7 @@ if ActiveRecord::Base.connection.supports_migrations?
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
uses_mocha 'Sexy migration tests' do
|
||||
class SexyMigrationsTest < ActiveRecord::TestCase
|
||||
def test_references_column_type_adds_id
|
||||
|
|
Loading…
Reference in a new issue