Permalink
Browse files

Add tests for scoping schema_migrations index by global table prefix …

…and suffix

[#1543 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
cristibalan authored and jeremy committed Aug 9, 2009
1 parent 7eaed4f commit 3e35ba248154209d9c46e3d9fa78e98c1b5d0a96
Showing with 18 additions and 0 deletions.
  1. +18 −0 activerecord/test/cases/migration_test.rb
@@ -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

0 comments on commit 3e35ba2

Please sign in to comment.