fixed the uniqueness on indecies and foreign key constrains in the down migrations

This commit is contained in:
Ilya Zhitomirskiy 2011-10-18 12:36:18 -07:00
parent 2b081df9fd
commit 9b6275640d
2 changed files with 7 additions and 6 deletions

View file

@ -10,7 +10,7 @@ class CommentAnything < ActiveRecord::Migration
def self.down
rename_column :comments, :commentable_id, :post_id
add_foreign_key :comments, :posts
add_foreign_key :comments, :posts, :dependent => :delete
add_index :comments, :post_id
remove_column :comments, :commentable_type

View file

@ -38,9 +38,9 @@ class ShareAnything < ActiveRecord::Migration
t.rename :shareable_id, :post_id
end
add_index :post_visibilities, [:post_id, :hidden, :contact_id]
add_index :post_visibilities, [:contact_id, :post_id]
add_foreign_key :post_visibilities, :posts
add_index :post_visibilities, [:post_id, :hidden, :contact_id], :unique => true
add_index :post_visibilities, [:contact_id, :post_id], :unique => true
add_foreign_key :post_visibilities, :posts, :dependent => :delete
remove_index :aspect_visibilities, [:shareable_id, :shareable_type]
@ -52,7 +52,8 @@ class ShareAnything < ActiveRecord::Migration
end
add_index :aspect_visibilities, :post_id
add_index :aspect_visibilities, [:post_id, :aspect_id]
add_foreign_key :aspect_visibilities, :posts
add_index :aspect_visibilities, [:post_id, :aspect_id], :unique => true
add_foreign_key :aspect_visibilities, :posts, :dependent => :delete
end
end