From 9b6275640d1c9e7a67c4372fd5b8dd0d5e66687e Mon Sep 17 00:00:00 2001 From: Ilya Zhitomirskiy Date: Tue, 18 Oct 2011 12:36:18 -0700 Subject: [PATCH] fixed the uniqueness on indecies and foreign key constrains in the down migrations --- db/migrate/20111011194702_comment_anything.rb | 2 +- db/migrate/20111011195702_share_anything.rb | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) 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