add unique index

This commit is contained in:
Raphael Sofaer 2011-03-30 11:18:04 -07:00
parent 22b9f92c27
commit 6e0315965b
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,9 @@
class TagUniqueness < ActiveRecord::Migration
def self.up
add_index :taggings, [:taggable_id, :taggable_type, :context, :tag_id], :unique => true, :name => 'index_taggings_uniquely'
end
def self.down
remove_index :taggings, :name => 'index_taggings_uniquely'
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110328202414) do
ActiveRecord::Schema.define(:version => 20110330175950) do
create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false
@ -328,6 +328,7 @@ ActiveRecord::Schema.define(:version => 20110328202414) do
end
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
add_index "taggings", ["taggable_id", "taggable_type", "context", "tag_id"], :name => "index_taggings_uniquely", :unique => true
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
create_table "tags", :force => true do |t|