aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/migration_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-12-20 22:28:12 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-12-20 22:28:12 +0000
commitb72763a96f0c936699d0f211be553f8f75accd07 (patch)
tree8951fa0f5b633df9927cc95e8234705938893dd4 /activerecord/test/migration_test.rb
parentf16cd7220ff94ea2ec5b9b8a7db02af0b5365858 (diff)
downloadrails-b72763a96f0c936699d0f211be553f8f75accd07.tar.gz
rails-b72763a96f0c936699d0f211be553f8f75accd07.tar.bz2
rails-b72763a96f0c936699d0f211be553f8f75accd07.zip
SQLite: fix rename_ and remove_column for columns with unique indexes. Closes #10576.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8453 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/migration_test.rb')
-rw-r--r--activerecord/test/migration_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index 64b8d51f39..0113cc1796 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -431,6 +431,44 @@ if ActiveRecord::Base.connection.supports_migrations?
end
end
+ def test_rename_column_with_an_index
+ ActiveRecord::Base.connection.create_table(:hats) do |table|
+ table.column :hat_name, :string, :limit => 100
+ table.column :hat_size, :integer
+ end
+ Person.connection.add_index :people, :first_name
+ assert_nothing_raised do
+ Person.connection.rename_column "hats", "hat_name", "name"
+ end
+ ensure
+ ActiveRecord::Base.connection.drop_table(:hats)
+ end
+
+ def test_remove_column_with_index
+ ActiveRecord::Base.connection.create_table(:hats) do |table|
+ table.column :hat_name, :string, :limit => 100
+ table.column :hat_size, :integer
+ end
+ ActiveRecord::Base.connection.add_index "hats", "hat_size"
+
+ assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") }
+ ensure
+ ActiveRecord::Base.connection.drop_table(:hats)
+ end
+
+ def test_remove_column_with_multi_column_index
+ ActiveRecord::Base.connection.create_table(:hats) do |table|
+ table.column :hat_name, :string, :limit => 100
+ table.column :hat_size, :integer
+ table.column :hat_style, :string, :limit => 100
+ end
+ ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true
+
+ assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") }
+ ensure
+ ActiveRecord::Base.connection.drop_table(:hats)
+ end
+
def test_change_type_of_not_null_column
assert_nothing_raised do
Topic.connection.change_column "topics", "written_on", :datetime, :null => false