提交 3e35ba24 编写于 作者: C Cristi Balan 提交者: Jeremy Kemper

Add tests for scoping schema_migrations index by global table prefix and suffix

[#1543 state:committed]
Signed-off-by: NJeremy Kemper <jeremy@bitsweat.net>
上级 7eaed4fe
......@@ -25,6 +25,24 @@ def puts(text="")
end
end
class MigrationTableAndIndexTest < ActiveRecord::TestCase
def test_add_schema_info_respects_prefix_and_suffix
conn = ActiveRecord::Base.connection
conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name)
ActiveRecord::Base.table_name_prefix = 'foo_'
ActiveRecord::Base.table_name_suffix = '_bar'
conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name)
conn.initialize_schema_migrations_table
assert_equal "foo_unique_schema_migrations_bar", conn.indexes(ActiveRecord::Migrator.schema_migrations_table_name)[0][:name]
ensure
ActiveRecord::Base.table_name_prefix = ""
ActiveRecord::Base.table_name_suffix = ""
end
end
class MigrationTest < ActiveRecord::TestCase
self.use_transactional_fixtures = false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册