demarches-normaliennes/db/migrate/20170307092820_move_mails_to_new_system.rb

12 lines
601 B
Ruby
Raw Normal View History

2017-03-07 10:40:16 +01:00
class MoveMailsToNewSystem < ActiveRecord::Migration[5.0]
def up
execute 'INSERT INTO received_mails (object, body, procedure_id, created_at, updated_at)
SELECT object, body, procedure_id, mail_templates.created_at, mail_templates.updated_at from mail_templates inner join procedures on mail_templates.procedure_id = procedures.id;'
execute "UPDATE received_mails set created_at='1980-01-01 00:00', updated_at='1980-01-01 00:00' where created_at is NULL"
change_column_null :received_mails, :created_at, false
change_column_null :received_mails, :updated_at, false
end
end