Replace some migrations that rely on relationships between
models to add subscriptions with rake tasks.
class SubscribeOldChangesets < ActiveRecord::Migration[4.2]
- class Changeset < ActiveRecord::Base
- end
-
- def up
- Changeset.find_each do |changeset|
- changeset.subscribers << changeset.user unless changeset.subscribers.exists?(changeset.user.id)
- end
- end
+ def up; end
def down; end
end
class SubscribeAuthorsToDiaryEntries < ActiveRecord::Migration[4.2]
- class DiaryEntry < ActiveRecord::Base
- end
-
- 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 up; end
def down; end
end
--- /dev/null
+namespace :db do
+ task :subscribe_diary_authors => :environment do
+ 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
+end
--- /dev/null
+namespace :db do
+ task :subscribe_old_changesets => :environment do
+ Changeset.find_each do |changeset|
+ changeset.subscribers << changeset.user unless changeset.subscribers.exists?(changeset.user.id)
+ end
+ end
+end