mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
Add comment reminder to add template redacted when creating a template
through a migration. Also fix the downgrades so they delete everything that needs deleting.
This commit is contained in:
@@ -47,6 +47,16 @@ If you didn’t try to register for a GOV.UK Notify account recently, please let
|
|||||||
datetime.utcnow(), content, service_id,
|
datetime.utcnow(), content, service_id,
|
||||||
'Your GOV.UK Notify account', user_id))
|
'Your GOV.UK Notify account', user_id))
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('0880fbb1-a0c6-46f0-9a8e-36c986381ceb', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(False, datetime.utcnow(), user_id)
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
op.execute("delete from notifications where template_id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
op.execute("delete from notifications where template_id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ Create Date: 2016-10-11 09:24:45.669018
|
|||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
revision = '0057_change_email_template'
|
revision = '0057_change_email_template'
|
||||||
down_revision = '0056_minor_updates'
|
down_revision = '0056_minor_updates'
|
||||||
|
|
||||||
from alembic import op
|
user_id = '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
||||||
user_id= '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
|
||||||
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||||
template_id = 'eb4d9930-87ab-4aef-9bce-786762687884'
|
template_id = 'eb4d9930-87ab-4aef-9bce-786762687884'
|
||||||
|
|
||||||
@@ -49,7 +49,19 @@ def upgrade():
|
|||||||
service_id,
|
service_id,
|
||||||
template_name, user_id))
|
template_name, user_id))
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(template_id, False, datetime.utcnow(), user_id)
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
op.execute("delete from templates_history where id = '{}'".format(template_id))
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(template_id))
|
||||||
op.execute("delete from templates where id = '{}'".format(template_id))
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id))
|
||||||
|
op.execute("delete from templates_history where id = '{}'".format(template_id))
|
||||||
|
op.execute("delete from templates where id = '{}'".format(template_id))
|
||||||
|
|||||||
@@ -113,7 +113,19 @@ GOV.UK Notify team
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(template_id, False, datetime.utcnow(), current_app.config['NOTIFY_USER_ID'])
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(template_id))
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
||||||
|
|||||||
@@ -65,7 +65,20 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(template_id, False, datetime.utcnow(), current_app.config['NOTIFY_USER_ID'])
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(template_id))
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id))
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ template_id = '203566f0-d835-47c5-aa06-932439c86573'
|
|||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
template_insert = """
|
template_insert = """
|
||||||
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
|
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
|
||||||
created_by_id, version, process_type, hidden)
|
created_by_id, version, process_type, hidden)
|
||||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}', false)
|
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}', false)
|
||||||
"""
|
"""
|
||||||
template_history_insert = """
|
template_history_insert = """
|
||||||
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
|
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
|
||||||
created_by_id, version, process_type, hidden)
|
created_by_id, version, process_type, hidden)
|
||||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}', false)
|
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}', false)
|
||||||
"""
|
"""
|
||||||
@@ -72,11 +72,24 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(template_id, False, datetime.utcnow(), current_app.config['NOTIFY_USER_ID'])
|
||||||
|
# )
|
||||||
|
|
||||||
# clean up constraints on org_to_service - service_id-org_id constraint is redundant
|
# clean up constraints on org_to_service - service_id-org_id constraint is redundant
|
||||||
op.drop_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', type_='unique')
|
op.drop_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', type_='unique')
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id))
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
||||||
|
op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id))
|
||||||
op.create_unique_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', ['service_id', 'organisation_id'])
|
op.create_unique_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', ['service_id', 'organisation_id'])
|
||||||
|
|||||||
@@ -108,10 +108,34 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(email_template_id, False, datetime.utcnow(), current_app.config['NOTIFY_USER_ID'])
|
||||||
|
# )
|
||||||
|
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(mobile_template_id, False, datetime.utcnow(), current_app.config['NOTIFY_USER_ID'])
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(email_template_id))
|
||||||
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(email_template_id))
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id))
|
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id))
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id))
|
op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id))
|
||||||
|
op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(email_template_id))
|
||||||
|
|
||||||
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(mobile_template_id))
|
||||||
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(mobile_template_id))
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(mobile_template_id))
|
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(mobile_template_id))
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(mobile_template_id))
|
op.execute("DELETE FROM templates WHERE id = '{}'".format(mobile_template_id))
|
||||||
|
op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(mobile_template_id))
|
||||||
|
|||||||
@@ -76,9 +76,20 @@ def upgrade():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If you are copying this migration, please remember about an insert to TemplateRedacted,
|
||||||
|
# which was not originally included here either by mistake or because it was before TemplateRedacted existed
|
||||||
|
# op.execute(
|
||||||
|
# """
|
||||||
|
# INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id)
|
||||||
|
# VALUES ('{}', '{}', '{}', '{}')
|
||||||
|
# ;
|
||||||
|
# """.format(email_template_id, False, datetime.utcnow(), current_app.config['NOTIFY_USER_ID'])
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(email_template_id))
|
op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(email_template_id))
|
||||||
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(email_template_id))
|
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(email_template_id))
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id))
|
op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id))
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id))
|
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id))
|
||||||
|
op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(email_template_id))
|
||||||
|
|||||||
Reference in New Issue
Block a user