diff --git a/db/migrate/20111011194702_comment_anything.rb b/db/migrate/20111011194702_comment_anything.rb index 1a59862b1..1af52245c 100644 --- a/db/migrate/20111011194702_comment_anything.rb +++ b/db/migrate/20111011194702_comment_anything.rb @@ -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 diff --git a/db/migrate/20111011195702_share_anything.rb b/db/migrate/20111011195702_share_anything.rb index 65d51ae8d..a7cdda2d9 100644 --- a/db/migrate/20111011195702_share_anything.rb +++ b/db/migrate/20111011195702_share_anything.rb @@ -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