From fb7e9dfcb315a637b10f18d3f98a4a0f8c3bdb69 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Tue, 12 Jul 2016 13:45:19 +0100 Subject: [PATCH] copy existing notifications into history table --- .../versions/0042_notification_history.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/migrations/versions/0042_notification_history.py b/migrations/versions/0042_notification_history.py index 4ae8be593..ac506ba9c 100644 --- a/migrations/versions/0042_notification_history.py +++ b/migrations/versions/0042_notification_history.py @@ -46,6 +46,46 @@ def upgrade(): op.create_index(op.f('ix_notification_history_reference'), 'notification_history', ['reference'], unique=False) op.create_index(op.f('ix_notification_history_service_id'), 'notification_history', ['service_id'], unique=False) op.create_index(op.f('ix_notification_history_template_id'), 'notification_history', ['template_id'], unique=False) + + op.execute(''' + INSERT INTO notification_history + ( + id, + job_id, + job_row_number, + service_id, + template_id, + template_version, + api_key_id, + key_type, + content_char_count, + notification_type, + created_at, + sent_at, + sent_by, + updated_at, + status, + reference + ) + SELECT + id, + job_id, + job_row_number, + service_id, + template_id, + template_version, + api_key_id, + key_type, + content_char_count, + notification_type, + created_at, + sent_at, + sent_by, + updated_at, + status, + reference + FROM notifications + ''') ### end Alembic commands ###