diff --git a/db/migrate/20170307092820_move_mails_to_new_system.rb b/db/migrate/20170307092820_move_mails_to_new_system.rb new file mode 100644 index 000000000..02b41ced3 --- /dev/null +++ b/db/migrate/20170307092820_move_mails_to_new_system.rb @@ -0,0 +1,11 @@ +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 diff --git a/db/schema.rb b/db/schema.rb index 1aff0250d..3e739f4ef 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170306102320) do +ActiveRecord::Schema.define(version: 20170307092820) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"