Workaround a problem with SQLite 3 and long index names

Index names can only be a certain length. The remove_user_from_taggings
migration, when run on sqlite3, creates an index name that violates the
maximum length check. Fix it by removing and then recreating the indexes
as part of the migration.
This commit is contained in:
Matt Rogers 2012-05-05 21:46:32 -05:00
parent fc69c6cfbf
commit a97384f318

View file

@ -1,9 +1,18 @@
class RemoveUserFromTaggings < ActiveRecord::Migration
def self.up
remove_index :taggings, [:tag_id, :taggable_id, :taggable_type]
remove_index :tags, :name
remove_column :taggings, :user_id
add_index :tags, :name
add_index :taggings, [:tag_id, :taggable_id, :taggable_type]
end
def self.down
remove_index :taggings, [:tag_id, :taggable_id, :taggable_type]
remove_index :tags, :name
add_column :taggings, :user_id, :integer
add_index :tags, :name
add_index :taggings, [:tag_id, :taggable_id, :taggable_type]
end
end
end