mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-26 01:03:41 -04:00
more files
This commit is contained in:
@@ -9,6 +9,8 @@ Create Date: 2017-04-24 15:12:18.907629
|
|||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from sqlalchemy import text
|
||||||
|
|
||||||
revision = '0075_create_rates_table'
|
revision = '0075_create_rates_table'
|
||||||
down_revision = '0074_update_sms_rate'
|
down_revision = '0074_update_sms_rate'
|
||||||
|
|
||||||
@@ -28,11 +30,17 @@ def upgrade():
|
|||||||
|
|
||||||
op.create_index(op.f('ix_rates_notification_type'), 'rates', ['notification_type'], unique=False)
|
op.create_index(op.f('ix_rates_notification_type'), 'rates', ['notification_type'], unique=False)
|
||||||
|
|
||||||
op.get_bind()
|
conn = op.get_bind()
|
||||||
op.execute("INSERT INTO rates(id, valid_from, rate, notification_type) "
|
input_params = {
|
||||||
"VALUES('{}', '2016-05-18 00:00:00', 1.65, 'sms')".format(uuid.uuid4()))
|
"id": uuid.uuid4()
|
||||||
op.execute("INSERT INTO rates(id, valid_from, rate, notification_type) "
|
}
|
||||||
"VALUES('{}', '2017-04-01 00:00:00', 1.58, 'sms')".format(uuid.uuid4()))
|
conn.execute(text("INSERT INTO rates(id, valid_from, rate, notification_type) "
|
||||||
|
"VALUES(:id, '2016-05-18 00:00:00', 1.65, 'sms')"), input_params)
|
||||||
|
input_params = {
|
||||||
|
"id": uuid.uuid4()
|
||||||
|
}
|
||||||
|
conn.execute(text("INSERT INTO rates(id, valid_from, rate, notification_type) "
|
||||||
|
"VALUES(:id, '2017-04-01 00:00:00', 1.58, 'sms')"), input_params)
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from flask import current_app
|
|||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy import text
|
||||||
|
|
||||||
revision = '0082_add_go_live_template'
|
revision = '0082_add_go_live_template'
|
||||||
down_revision = '0081_noti_status_as_enum'
|
down_revision = '0081_noti_status_as_enum'
|
||||||
@@ -23,11 +24,11 @@ template_id = '618185c6-3636-49cd-b7d2-6f6f5eb3bdde'
|
|||||||
def upgrade():
|
def upgrade():
|
||||||
template_insert = """
|
template_insert = """
|
||||||
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
||||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}')
|
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id, :subject, :user_id, 1, :process_type)
|
||||||
"""
|
"""
|
||||||
template_history_insert = """
|
template_history_insert = """
|
||||||
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
||||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}')
|
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id, :subject, :user_id, 1, :process_type)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template_content = """Hi ((name)),
|
template_content = """Hi ((name)),
|
||||||
@@ -85,47 +86,33 @@ GOV.UK Notify team
|
|||||||
template_name = "Automated \"You''re now live\" message"
|
template_name = "Automated \"You''re now live\" message"
|
||||||
template_subject = '((service name)) is now live on GOV.UK Notify'
|
template_subject = '((service name)) is now live on GOV.UK Notify'
|
||||||
|
|
||||||
op.execute(
|
input_params = {
|
||||||
template_history_insert.format(
|
'template_id': template_id,
|
||||||
template_id,
|
'template_name': template_name,
|
||||||
template_name,
|
'template_type': 'email',
|
||||||
'email',
|
'time_now': datetime.utcnow(),
|
||||||
datetime.utcnow(),
|
'content': template_content,
|
||||||
template_content,
|
'notify_service_id': current_app.config['NOTIFY_SERVICE_ID'],
|
||||||
current_app.config['NOTIFY_SERVICE_ID'],
|
'subject': template_subject,
|
||||||
template_subject,
|
'user_id': current_app.config['NOTIFY_USER_ID'],
|
||||||
current_app.config['NOTIFY_USER_ID'],
|
'process_type': 'normal'
|
||||||
'normal'
|
}
|
||||||
)
|
conn = op.get_bind()
|
||||||
|
conn.execute(
|
||||||
|
text(template_history_insert), input_params
|
||||||
)
|
)
|
||||||
|
|
||||||
op.execute(
|
conn.execute(
|
||||||
template_insert.format(
|
text(template_insert), input_params
|
||||||
template_id,
|
|
||||||
template_name,
|
|
||||||
'email',
|
|
||||||
datetime.utcnow(),
|
|
||||||
template_content,
|
|
||||||
current_app.config['NOTIFY_SERVICE_ID'],
|
|
||||||
template_subject,
|
|
||||||
current_app.config['NOTIFY_USER_ID'],
|
|
||||||
'normal'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# 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 notifications WHERE template_id = '{}'".format(template_id))
|
input_params = {
|
||||||
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id))
|
"template_id": template_id
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
}
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
conn = op.get_bind()
|
||||||
|
conn.execute(text("DELETE FROM notifications WHERE template_id = '{}'"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM notification_history WHERE template_id = '{}'"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM templates_history WHERE id = '{}'"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM templates WHERE id = '{}'"), input_params)
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ Create Date: 2017-06-29 12:44:16.815039
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
|
from sqlalchemy import text
|
||||||
|
|
||||||
revision = '0103_add_historical_redact'
|
revision = '0103_add_historical_redact'
|
||||||
down_revision = 'db6d9d9f06bc'
|
down_revision = 'db6d9d9f06bc'
|
||||||
|
|
||||||
@@ -15,8 +17,14 @@ import sqlalchemy as sa
|
|||||||
from sqlalchemy.dialects import postgresql
|
from sqlalchemy.dialects import postgresql
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
op.execute(
|
conn = op.get_bind()
|
||||||
|
input_params = {
|
||||||
|
"notify_user_id": current_app.config['NOTIFY_USER_ID']
|
||||||
|
}
|
||||||
|
conn.execute(
|
||||||
|
text(
|
||||||
"""
|
"""
|
||||||
INSERT INTO template_redacted
|
INSERT INTO template_redacted
|
||||||
(
|
(
|
||||||
@@ -29,12 +37,12 @@ def upgrade():
|
|||||||
templates.id,
|
templates.id,
|
||||||
false,
|
false,
|
||||||
now(),
|
now(),
|
||||||
'{notify_user}'
|
:notify_user_id
|
||||||
FROM
|
FROM
|
||||||
templates
|
templates
|
||||||
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
|
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
|
||||||
WHERE template_redacted.template_id IS NULL
|
WHERE template_redacted.template_id IS NULL
|
||||||
""".format(notify_user=current_app.config['NOTIFY_USER_ID'])
|
"""), input_params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
from sqlalchemy import text
|
||||||
|
|
||||||
revision = '0134_add_email_2fa_template'
|
revision = '0134_add_email_2fa_template'
|
||||||
down_revision = '0133_set_services_sms_prefix'
|
down_revision = '0133_set_services_sms_prefix'
|
||||||
@@ -20,11 +20,11 @@ template_id = '299726d2-dba6-42b8-8209-30e1d66ea164'
|
|||||||
def upgrade():
|
def upgrade():
|
||||||
template_insert = """
|
template_insert = """
|
||||||
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
||||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}')
|
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id, :subject, :user_id, 1,:process_type)
|
||||||
"""
|
"""
|
||||||
template_history_insert = """
|
template_history_insert = """
|
||||||
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject, created_by_id, version, process_type)
|
||||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}')
|
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id, :subject, :user_id, 1,:process_type)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template_content = '\n'.join([
|
template_content = '\n'.join([
|
||||||
@@ -37,48 +37,35 @@ def upgrade():
|
|||||||
template_name = "Notify email verify code"
|
template_name = "Notify email verify code"
|
||||||
template_subject = 'Sign in to GOV.UK Notify'
|
template_subject = 'Sign in to GOV.UK Notify'
|
||||||
|
|
||||||
op.execute(
|
input_params = {
|
||||||
template_history_insert.format(
|
'template_id': template_id,
|
||||||
template_id,
|
'template_name': template_name,
|
||||||
template_name,
|
'template_type': 'email',
|
||||||
'email',
|
'time_now': datetime.utcnow(),
|
||||||
datetime.utcnow(),
|
'content': template_content,
|
||||||
template_content,
|
'notify_service_id': current_app.config['NOTIFY_SERVICE_ID'],
|
||||||
current_app.config['NOTIFY_SERVICE_ID'],
|
'subject': template_subject,
|
||||||
template_subject,
|
'user_id': current_app.config['NOTIFY_USER_ID'],
|
||||||
current_app.config['NOTIFY_USER_ID'],
|
'process_type': 'normal'
|
||||||
'normal'
|
}
|
||||||
)
|
conn = op.get_bind()
|
||||||
|
|
||||||
|
conn.execute(
|
||||||
|
text(template_history_insert), input_params
|
||||||
)
|
)
|
||||||
|
|
||||||
op.execute(
|
conn.execute(
|
||||||
template_insert.format(
|
text(template_insert), input_params
|
||||||
template_id,
|
|
||||||
template_name,
|
|
||||||
'email',
|
|
||||||
datetime.utcnow(),
|
|
||||||
template_content,
|
|
||||||
current_app.config['NOTIFY_SERVICE_ID'],
|
|
||||||
template_subject,
|
|
||||||
current_app.config['NOTIFY_USER_ID'],
|
|
||||||
'normal'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# 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 notifications WHERE template_id = '{}'".format(template_id))
|
conn = op.get_bind()
|
||||||
op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id))
|
input_params = {
|
||||||
op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id))
|
'template_id': template_id
|
||||||
op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id))
|
}
|
||||||
op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id))
|
conn.execute(text("DELETE FROM notifications WHERE template_id = :template_id"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM notification_history WHERE template_id = :template_id"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM template_redacted WHERE template_id = :template_id"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM templates_history WHERE id = :template_id"), input_params)
|
||||||
|
conn.execute(text("DELETE FROM templates WHERE id = :template_id"), input_params)
|
||||||
|
|||||||
21
migrations/versions/d2db89558026.py
Normal file
21
migrations/versions/d2db89558026.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"""
|
||||||
|
|
||||||
|
Revision ID: d2db89558026
|
||||||
|
Revises: 0395_add_total_message_limit
|
||||||
|
Create Date: 2023-04-27 14:59:39.428607
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
revision = 'd2db89558026'
|
||||||
|
down_revision = '0397_rename_organisation_2'
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user