break out author subscriptions to its own migration
authorMikel Maron <mikel_maron@yahoo.com>
Tue, 11 Oct 2016 01:18:03 +0000 (21:18 -0400)
committerMikel Maron <mikel_maron@yahoo.com>
Tue, 11 Oct 2016 01:18:03 +0000 (21:18 -0400)
db/migrate/20161002153425_add_join_table_between_users_and_diary_entries.rb
db/migrate/20161011010929_subscribe_authors_to_diary_entries.rb [new file with mode: 0644]

index ad642f9..4c41f72 100644 (file)
@@ -9,12 +9,4 @@ class AddJoinTableBetweenUsersAndDiaryEntries < ActiveRecord::Migration
     add_index :diary_entry_subscriptions, [:diary_entry_id]
   end
 
     add_index :diary_entry_subscriptions, [:diary_entry_id]
   end
 
-  def up
-    DiaryEntry.find_each do |diary_entry|
-      diary_entry.subscriptions.create(:user => diary_entry.user) unless diary_entry.subscribers.exists?(@user.id)
-    end
-  end
-
-  def down
-  end
 end
 end
diff --git a/db/migrate/20161011010929_subscribe_authors_to_diary_entries.rb b/db/migrate/20161011010929_subscribe_authors_to_diary_entries.rb
new file mode 100644 (file)
index 0000000..2dfbbf2
--- /dev/null
@@ -0,0 +1,10 @@
+class SubscribeAuthorsToDiaryEntries < ActiveRecord::Migration
+  def up
+    DiaryEntry.find_each do |diary_entry|
+      diary_entry.subscriptions.create(:user => diary_entry.user) unless diary_entry.subscribers.exists?(diary_entry.user.id)
+    end
+  end
+
+  def down
+  end
+end