Initial commit
This commit is contained in:
21
db/data_migrations/20200410183245_set_email_for_notes.rb
Normal file
21
db/data_migrations/20200410183245_set_email_for_notes.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class SetEmailForNotes < ActiveRecord::DataMigration
|
||||
def up
|
||||
say "Setting #email for Notes..."
|
||||
|
||||
Note.find_each do |note|
|
||||
if note.user.present? && note.user.email.present?
|
||||
note.update_column(:email, note.user.email)
|
||||
end
|
||||
end
|
||||
|
||||
say "Done."
|
||||
end
|
||||
|
||||
def down
|
||||
say "Unsetting #email for Notes..."
|
||||
|
||||
Note.update_all(email: nil)
|
||||
|
||||
say "Done."
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user