From dfa68883113045aad4bfab87c82b54d0c98d0a89 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 18 Mar 2008 18:23:14 +0000 Subject: Migrations: create_table supports primary_key_prefix_type. Closes #10314. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9056 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/cases/migration_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'activerecord/test/cases/migration_test.rb') diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 5dbfbd81c2..ebe563059d 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -181,6 +181,33 @@ if ActiveRecord::Base.connection.supports_migrations? Person.connection.drop_table :testings rescue nil end + def test_create_table_with_primary_key_prefix_as_table_name_with_underscore + ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore + + Person.connection.create_table :testings do |t| + t.column :foo, :string + end + + assert_equal %w(foo testings_id), Person.connection.columns(:testings).map { |c| c.name }.sort + ensure + Person.connection.drop_table :testings rescue nil + ActiveRecord::Base.primary_key_prefix_type = nil + end + + def test_create_table_with_primary_key_prefix_as_table_name + ActiveRecord::Base.primary_key_prefix_type = :table_name + + Person.connection.create_table :testings do |t| + t.column :foo, :string + end + + assert_equal %w(foo testingsid), Person.connection.columns(:testings).map { |c| c.name }.sort + ensure + Person.connection.drop_table :testings rescue nil + ActiveRecord::Base.primary_key_prefix_type = nil + end + + # SQL Server, Sybase, and SQLite3 will not allow you to add a NOT NULL # column to a table without a default value. unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :SQLiteAdapter) -- cgit v1.2.3