mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Initial commit for sqlalchemy2.0 migration
This commit is contained in:
@@ -25,7 +25,7 @@ def upgrade():
|
||||
"jobs", sa.Column("notifications_failed", sa.Integer(), nullable=True)
|
||||
)
|
||||
conn = op.get_bind()
|
||||
results = conn.execute("select distinct job_id from notifications")
|
||||
results = conn.execute(text("select distinct job_id from notifications"))
|
||||
res = results.fetchall()
|
||||
for x in res:
|
||||
if x.job_id:
|
||||
|
||||
@@ -32,9 +32,7 @@ def upgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(user_insert),
|
||||
user_id=user_id,
|
||||
time_now=datetime.utcnow(),
|
||||
password=password,
|
||||
{"user_id": user_id, "time_now": datetime.utcnow(), "password": password},
|
||||
)
|
||||
service_history_insert = """INSERT INTO services_history (id, name, created_at, active, message_limit, restricted, research_mode, email_from, created_by_id, reply_to_email_address, version)
|
||||
VALUES (:service_id, 'Notify service', :time_now, True, 1000, False, False, 'testsender@dispostable.com',
|
||||
@@ -43,9 +41,7 @@ def upgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(service_history_insert),
|
||||
service_id=service_id,
|
||||
time_now=datetime.utcnow(),
|
||||
user_id=user_id,
|
||||
{"service_id": service_id, "time_now": datetime.utcnow(), "user_id": user_id},
|
||||
)
|
||||
service_insert = """INSERT INTO services (id, name, created_at, active, message_limit, restricted, research_mode, email_from, created_by_id, reply_to_email_address, version)
|
||||
VALUES (:service_id, 'Notify service', :time_now, True, 1000, False, False, 'testsender@dispostable.com',
|
||||
@@ -53,12 +49,12 @@ def upgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(service_insert),
|
||||
service_id=service_id,
|
||||
time_now=datetime.utcnow(),
|
||||
user_id=user_id,
|
||||
{"service_id": service_id, "time_now": datetime.utcnow(), "user_id": user_id},
|
||||
)
|
||||
user_to_service_insert = """INSERT INTO user_to_service (user_id, service_id) VALUES (:user_id, :service_id)"""
|
||||
conn.execute(text(user_to_service_insert), user_id=user_id, service_id=service_id)
|
||||
conn.execute(
|
||||
text(user_to_service_insert), {"user_id": user_id, "service_id": service_id}
|
||||
)
|
||||
|
||||
template_history_insert = """INSERT INTO templates_history (id, name, template_type, created_at,
|
||||
content, archived, service_id,
|
||||
@@ -74,25 +70,29 @@ def upgrade():
|
||||
email_verification_content = """Hi ((name)),\n\nTo complete your registration for GOV.UK Notify please click the link below\n\n((url))"""
|
||||
conn.execute(
|
||||
text(template_history_insert),
|
||||
template_id=uuid.uuid4(),
|
||||
template_name="Notify email verification code",
|
||||
template_type="email",
|
||||
time_now=datetime.utcnow(),
|
||||
content=email_verification_content,
|
||||
service_id=service_id,
|
||||
subject="Confirm GOV.UK Notify registration",
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": uuid.uuid4(),
|
||||
"template_name": "Notify email verification code",
|
||||
"template_type": "email",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": email_verification_content,
|
||||
"service_id": service_id,
|
||||
"subject": "Confirm GOV.UK Notify registration",
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
conn.execute(
|
||||
text(template_insert),
|
||||
template_id="ece42649-22a8-4d06-b87f-d52d5d3f0a27",
|
||||
template_name="Notify email verification code",
|
||||
template_type="email",
|
||||
time_now=datetime.utcnow(),
|
||||
content=email_verification_content,
|
||||
service_id=service_id,
|
||||
subject="Confirm GOV.UK Notify registration",
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "ece42649-22a8-4d06-b87f-d52d5d3f0a27",
|
||||
"template_name": "Notify email verification code",
|
||||
"template_type": "email",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": email_verification_content,
|
||||
"service_id": service_id,
|
||||
"subject": "Confirm GOV.UK Notify registration",
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
|
||||
invitation_subject = "((user_name)) has invited you to collaborate on ((service_name)) on GOV.UK Notify"
|
||||
@@ -103,50 +103,58 @@ def upgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(template_history_insert),
|
||||
template_id="4f46df42-f795-4cc4-83bb-65ca312f49cc",
|
||||
template_name="Notify invitation email",
|
||||
template_type="email",
|
||||
time_now=datetime.utcnow(),
|
||||
content=invitation_content,
|
||||
service_id=service_id,
|
||||
subject=invitation_subject,
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "4f46df42-f795-4cc4-83bb-65ca312f49cc",
|
||||
"template_name": "Notify invitation email",
|
||||
"template_type": "email",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": invitation_content,
|
||||
"service_id": service_id,
|
||||
"subject": invitation_subject,
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
conn.execute(
|
||||
text(template_insert),
|
||||
template_id="4f46df42-f795-4cc4-83bb-65ca312f49cc",
|
||||
template_name="Notify invitation email",
|
||||
template_type="email",
|
||||
time_now=datetime.utcnow(),
|
||||
content=invitation_content,
|
||||
service_id=service_id,
|
||||
subject=invitation_subject,
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "4f46df42-f795-4cc4-83bb-65ca312f49cc",
|
||||
"template_name": "Notify invitation email",
|
||||
"template_type": "email",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": invitation_content,
|
||||
"service_id": service_id,
|
||||
"subject": invitation_subject,
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
|
||||
sms_code_content = "((verify_code)) is your US Notify authentication code"
|
||||
conn.execute(
|
||||
text(template_history_insert),
|
||||
template_id="36fb0730-6259-4da1-8a80-c8de22ad4246",
|
||||
template_name="Notify SMS verify code",
|
||||
template_type="sms",
|
||||
time_now=datetime.utcnow(),
|
||||
content=sms_code_content,
|
||||
service_id=service_id,
|
||||
subject=None,
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "36fb0730-6259-4da1-8a80-c8de22ad4246",
|
||||
"template_name": "Notify SMS verify code",
|
||||
"template_type": "sms",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": sms_code_content,
|
||||
"service_id": service_id,
|
||||
"subject": None,
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
|
||||
conn.execute(
|
||||
text(template_insert),
|
||||
template_id="36fb0730-6259-4da1-8a80-c8de22ad4246",
|
||||
template_name="Notify SMS verify code",
|
||||
template_type="sms",
|
||||
time_now=datetime.utcnow(),
|
||||
content=sms_code_content,
|
||||
service_id=service_id,
|
||||
subject=None,
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "36fb0730-6259-4da1-8a80-c8de22ad4246",
|
||||
"template_name": "Notify SMS verify code",
|
||||
"template_type": "sms",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": sms_code_content,
|
||||
"service_id": service_id,
|
||||
"subject": None,
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
|
||||
password_reset_content = (
|
||||
@@ -160,25 +168,30 @@ def upgrade():
|
||||
|
||||
conn.execute(
|
||||
text(template_history_insert),
|
||||
template_id="474e9242-823b-4f99-813d-ed392e7f1201",
|
||||
template_name="Notify password reset email",
|
||||
template_type="email",
|
||||
time_now=datetime.utcnow(),
|
||||
content=password_reset_content,
|
||||
service_id=service_id,
|
||||
subject="Reset your GOV.UK Notify password",
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "474e9242-823b-4f99-813d-ed392e7f1201",
|
||||
"template_name": "Notify password reset email",
|
||||
"template_type": "email",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": password_reset_content,
|
||||
"service_id": service_id,
|
||||
"subject": "Reset your GOV.UK Notify password",
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
|
||||
conn.execute(
|
||||
text(template_insert),
|
||||
template_id="474e9242-823b-4f99-813d-ed392e7f1201",
|
||||
template_name="Notify password reset email",
|
||||
template_type="email",
|
||||
time_now=datetime.utcnow(),
|
||||
content=password_reset_content,
|
||||
service_id=service_id,
|
||||
subject="Reset your GOV.UK Notify password",
|
||||
user_id=user_id,
|
||||
{
|
||||
"template_id": "474e9242-823b-4f99-813d-ed392e7f1201",
|
||||
"template_name": "Notify password reset email",
|
||||
"template_type": "email",
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": password_reset_content,
|
||||
"service_id": service_id,
|
||||
"subject": "Reset your GOV.UK Notify password",
|
||||
"user_id": user_id,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ def upgrade():
|
||||
"sms_requested = 0, sms_delivered = 0, sms_failed=0 where day > '2016-06-30'"
|
||||
)
|
||||
op.execute(reset_counts)
|
||||
all_notifications = "select * from notifications where date(created_at) > '2016-06-30' order by created_at;"
|
||||
all_notifications = text(
|
||||
"select * from notifications where date(created_at) > '2016-06-30' order by created_at;"
|
||||
)
|
||||
|
||||
results = conn.execute(all_notifications)
|
||||
res = results.fetchall()
|
||||
|
||||
@@ -34,11 +34,12 @@ def upgrade():
|
||||
# caveats
|
||||
# only adjusts notifications for services that have never been in research mode. On live, research mode was
|
||||
# limited to only services that we have set up ourselves so deemed this acceptable.
|
||||
billable_services = conn.execute(
|
||||
billable_services_query = text(
|
||||
"""
|
||||
SELECT id FROM services_history WHERE id not in (select id from services_history where research_mode)
|
||||
SELECT id FROM services_history WHERE id NOT IN (SELECT id FROM services_history WHERE research_mode)
|
||||
"""
|
||||
)
|
||||
billable_services = conn.execute(billable_services_query)
|
||||
# set to 'null' if there are no billable services so we don't get a syntax error in the update statement
|
||||
service_ids = ",".join(f"{service.id}" for service in billable_services) or "null"
|
||||
|
||||
@@ -73,11 +74,11 @@ def upgrade():
|
||||
query = text(update_statement_n).bindparams(
|
||||
bindparam("service_ids", expanding=False)
|
||||
)
|
||||
conn.execute(query, service_ids=service_ids)
|
||||
conn.execute(query, {"service_ids": service_ids})
|
||||
query = text(update_statement_nh).bindparams(
|
||||
bindparam("service_ids", expanding=False)
|
||||
)
|
||||
conn.execute(query, service_ids=service_ids)
|
||||
conn.execute(query, {"service_ids": service_ids})
|
||||
op.drop_column("notifications", "content_char_count")
|
||||
op.drop_column("notification_history", "content_char_count")
|
||||
|
||||
@@ -130,11 +131,11 @@ def downgrade():
|
||||
query = text(update_statement_n).bindparams(
|
||||
bindparam("service_ids", expanding=False)
|
||||
)
|
||||
conn.execute(query, service_ids=service_ids)
|
||||
conn.execute(query, {"service_ids": service_ids})
|
||||
query = text(update_statement_nh).bindparams(
|
||||
bindparam("service_ids", expanding=False)
|
||||
)
|
||||
conn.execute(query, service_ids=service_ids)
|
||||
conn.execute(query, {"service_ids": service_ids})
|
||||
|
||||
op.drop_column("notifications", "billable_units")
|
||||
op.drop_column("notification_history", "billable_units")
|
||||
|
||||
@@ -38,40 +38,46 @@ def upgrade():
|
||||
)
|
||||
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
|
||||
query = text(
|
||||
"""
|
||||
INSERT INTO service_permissions (service_id, permission, created_at)
|
||||
SELECT id, 'sms', '2017-05-26 17:30:00.000000' FROM services
|
||||
WHERE id NOT IN (SELECT service_id FROM service_permissions
|
||||
WHERE service_id=id AND permission='sms')
|
||||
INSERT INTO service_permissions (service_id, permission, created_at)
|
||||
SELECT id, 'sms', '2017-05-26 17:30:00.000000' FROM services
|
||||
WHERE id NOT IN (SELECT service_id FROM service_permissions
|
||||
WHERE service_id=id AND permission='sms')
|
||||
"""
|
||||
)
|
||||
conn.execute(query)
|
||||
|
||||
conn.execute(
|
||||
query = text(
|
||||
"""
|
||||
INSERT INTO service_permissions (service_id, permission, created_at)
|
||||
SELECT id, 'email', '2017-05-26 17:30:00.000000' FROM services
|
||||
WHERE id NOT IN (SELECT service_id FROM service_permissions
|
||||
WHERE service_id=id AND permission='email')
|
||||
"""
|
||||
"""
|
||||
)
|
||||
conn.execute(query)
|
||||
|
||||
conn.execute(
|
||||
query = text(
|
||||
"""
|
||||
INSERT INTO service_permissions (service_id, permission, created_at)
|
||||
SELECT id, 'letter', '2017-05-26 17:30:00.000000' FROM services
|
||||
WHERE can_send_letters AND id NOT IN (SELECT service_id FROM service_permissions
|
||||
WHERE service_id=id AND permission='letter')
|
||||
INSERT INTO service_permissions (service_id, permission, created_at)
|
||||
SELECT id, 'letter', '2017-05-26 17:30:00.000000' FROM services
|
||||
WHERE can_send_letters AND id NOT IN (SELECT service_id FROM service_permissions
|
||||
WHERE service_id=id AND permission='letter')
|
||||
"""
|
||||
)
|
||||
conn.execute(
|
||||
conn.execute(query)
|
||||
|
||||
query = text(
|
||||
"""
|
||||
INSERT INTO service_permissions (service_id, permission, created_at)
|
||||
SELECT id, 'international_sms', '2017-05-26 17:30:00.000000' FROM services
|
||||
WHERE can_send_international_sms AND id NOT IN (SELECT service_id FROM service_permissions
|
||||
WHERE service_id=id AND permission='international_sms')
|
||||
"""
|
||||
"""
|
||||
)
|
||||
conn.execute(query)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -12,15 +12,18 @@ down_revision = "0095_migrate_existing_svc_perms"
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
query = (
|
||||
"UPDATE job_statistics "
|
||||
"set sent = sms_sent + emails_sent + letters_sent, "
|
||||
" delivered = sms_delivered + emails_delivered, "
|
||||
" failed = sms_failed + emails_failed + letters_failed "
|
||||
query = text(
|
||||
"""
|
||||
UPDATE job_statistics
|
||||
SET sent = sms_sent + emails_sent + letters_sent,
|
||||
delivered = sms_delivered + emails_delivered,
|
||||
failed = sms_failed + emails_failed + letters_failed
|
||||
"""
|
||||
)
|
||||
|
||||
conn = op.get_bind()
|
||||
@@ -28,7 +31,14 @@ def upgrade():
|
||||
|
||||
|
||||
def downgrade():
|
||||
query = "UPDATE job_statistics " "set sent = 0, " " delivered = 0, " " failed = 0 "
|
||||
query = text(
|
||||
"""
|
||||
UPDATE job_statistics
|
||||
SET sent = 0,
|
||||
delivered = 0,
|
||||
failed = 0
|
||||
"""
|
||||
)
|
||||
|
||||
conn = op.get_bind()
|
||||
conn.execute(query)
|
||||
|
||||
@@ -24,7 +24,8 @@ def upgrade():
|
||||
op.add_column("monthly_billing", sa.Column("start_date", sa.DateTime))
|
||||
op.add_column("monthly_billing", sa.Column("end_date", sa.DateTime))
|
||||
conn = op.get_bind()
|
||||
results = conn.execute("Select id, month, year from monthly_billing")
|
||||
query = text("SELECT id, month, year FROM monthly_billing")
|
||||
results = conn.execute(query)
|
||||
res = results.fetchall()
|
||||
for x in res:
|
||||
start_date, end_date = get_month_start_and_end_date_in_utc(
|
||||
|
||||
@@ -48,15 +48,12 @@ def upgrade():
|
||||
)
|
||||
|
||||
for org_id, org_filename in LOGOS.items():
|
||||
conn.execute(
|
||||
text(
|
||||
"""
|
||||
query = text(
|
||||
"""
|
||||
UPDATE dvla_organisation SET filename = :filename WHERE id = :id
|
||||
"""
|
||||
),
|
||||
filename=org_filename,
|
||||
id=org_id,
|
||||
)
|
||||
conn.execute(query, {"filename": org_filename, "id": org_id})
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -6,6 +6,7 @@ Create Date: 2018-12-12 12:00:09.770775
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = "0246_notifications_index"
|
||||
down_revision = "0245_archived_flag_jobs"
|
||||
@@ -13,11 +14,13 @@ down_revision = "0245_archived_flag_jobs"
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
query = text(
|
||||
"CREATE INDEX IF NOT EXISTS ix_notifications_service_created_at ON notifications (service_id, created_at)"
|
||||
)
|
||||
conn.execute(query)
|
||||
|
||||
|
||||
def downgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute("DROP INDEX IF EXISTS ix_notifications_service_created_at")
|
||||
query = text("DROP INDEX IF EXISTS ix_notifications_service_created_at")
|
||||
conn.execute(query)
|
||||
|
||||
@@ -15,9 +15,8 @@ down_revision = "0302_add_org_id_to_services"
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
results = conn.execute(
|
||||
"select service_id, organisation_id from organisation_to_service"
|
||||
)
|
||||
query = text("SELECT service_id, organisation_id FROM organisation_to_service")
|
||||
results = conn.execute(query)
|
||||
org_to_service = results.fetchall()
|
||||
for x in org_to_service:
|
||||
sql = """
|
||||
@@ -27,8 +26,10 @@ def upgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(sql),
|
||||
service_id=str(x.service_id),
|
||||
organisation_id=str(x.organisation_id),
|
||||
{
|
||||
"service_id": str(x.service_id),
|
||||
"organisation_id": str(x.organisation_id),
|
||||
},
|
||||
)
|
||||
history_sql = """
|
||||
UPDATE services_history
|
||||
@@ -38,8 +39,10 @@ def upgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(history_sql),
|
||||
service_id=str(x.service_id),
|
||||
organisation_id=str(x.organisation_id),
|
||||
{
|
||||
"service_id": str(x.service_id),
|
||||
"organisation_id": str(x.organisation_id),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -65,8 +68,10 @@ def downgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(update_sql),
|
||||
service_id=str(x.id),
|
||||
organisation_id=str(x.organisation_id),
|
||||
{
|
||||
"service_id": str(x.service_id),
|
||||
"organisation_id": str(x.organisation_id),
|
||||
},
|
||||
)
|
||||
elif len(os) == 0:
|
||||
insert_sql = """
|
||||
@@ -74,8 +79,10 @@ def downgrade():
|
||||
"""
|
||||
conn.execute(
|
||||
text(insert_sql),
|
||||
service_id=str(x.id),
|
||||
organisation_id=str(x.organisation_id),
|
||||
{
|
||||
"service_id": str(x.service_id),
|
||||
"organisation_id": str(x.organisation_id),
|
||||
},
|
||||
)
|
||||
else:
|
||||
raise Exception(
|
||||
|
||||
@@ -17,9 +17,9 @@ down_revision = "0307_delete_dm_datetime"
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM provider_details WHERE identifier = 'loadtesting'")
|
||||
conn.execute(text("DELETE FROM provider_details WHERE identifier = 'loadtesting'"))
|
||||
conn.execute(
|
||||
"DELETE FROM provider_details_history WHERE identifier = 'loadtesting'"
|
||||
text("DELETE FROM provider_details_history WHERE identifier = 'loadtesting'")
|
||||
)
|
||||
|
||||
|
||||
@@ -40,5 +40,5 @@ def downgrade():
|
||||
(:uuid, 'Loadtesting', 'loadtesting', 100, 'sms', true, 1, false)
|
||||
"""
|
||||
),
|
||||
uuid=uuid.uuid4(),
|
||||
{"uuid": str(uuid.uuid4())},
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ def upgrade():
|
||||
values(uuid_in(md5(random()::text)::cstring), :updated_at, :service_id, :id, now(), null)
|
||||
"""
|
||||
|
||||
results = conn.execute(sql)
|
||||
results = conn.execute(text(sql))
|
||||
returned_letters = results.fetchall()
|
||||
for x in returned_letters:
|
||||
input_params = {
|
||||
|
||||
@@ -23,10 +23,10 @@ def upgrade():
|
||||
VALUES (:service_id, 'international_letters', now())
|
||||
"""
|
||||
conn = op.get_bind()
|
||||
results = conn.execute(sql)
|
||||
results = conn.execute(text(sql))
|
||||
services_to_add_permission = results.fetchall()
|
||||
for x in services_to_add_permission:
|
||||
conn.execute(text(insert_sql), service_id=x.service_id)
|
||||
conn.execute(text(insert_sql), {"service_id": x.service_id})
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -9,6 +9,7 @@ import os
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = "0331_add_broadcast_org"
|
||||
down_revision = "0330_broadcast_invite_email"
|
||||
@@ -53,17 +54,19 @@ def upgrade():
|
||||
"""
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
sa.text(insert_sql),
|
||||
id=organisation_id,
|
||||
name=f"Broadcast Services ({environment})",
|
||||
active=True,
|
||||
agreement_signed=None,
|
||||
crown=None,
|
||||
organisation_type="central",
|
||||
text(insert_sql),
|
||||
{
|
||||
"id": organisation_id,
|
||||
"name": f"Broadcast Services ({environment})",
|
||||
"active": True,
|
||||
"agreement_signed": None,
|
||||
"crown": None,
|
||||
"organisation_type": "central",
|
||||
},
|
||||
)
|
||||
conn.execute(
|
||||
sa.text(update_service_set_broadcast_org_sql),
|
||||
organisation_id=organisation_id,
|
||||
text(update_service_set_broadcast_org_sql),
|
||||
{"organisation_id": organisation_id},
|
||||
)
|
||||
|
||||
|
||||
@@ -79,6 +82,6 @@ def downgrade():
|
||||
"""
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
sa.text(update_service_remove_org_sql), organisation_id=organisation_id
|
||||
text(update_service_remove_org_sql), {"organisation_id": organisation_id}
|
||||
)
|
||||
conn.execute(sa.text(delete_sql), organisation_id=organisation_id)
|
||||
conn.execute(text(delete_sql), {"organisation_id": organisation_id})
|
||||
|
||||
@@ -29,7 +29,7 @@ def upgrade():
|
||||
values(:service_id, 'test', :provider, now(), null)
|
||||
"""
|
||||
conn = op.get_bind()
|
||||
results = conn.execute(sql)
|
||||
results = conn.execute(text(sql))
|
||||
restrictions = results.fetchall()
|
||||
for x in restrictions:
|
||||
input_params = {"service_id": x.service_id, "provider": x.provider}
|
||||
|
||||
@@ -33,7 +33,7 @@ def upgrade():
|
||||
WHERE service_permissions.permission = 'broadcast'
|
||||
"""
|
||||
|
||||
services = conn.execute(find_services_sql)
|
||||
services = conn.execute(text(find_services_sql))
|
||||
for service in services:
|
||||
input_params = {"service_id": service.id}
|
||||
setting = conn.execute(
|
||||
|
||||
@@ -26,14 +26,16 @@ def upgrade():
|
||||
|
||||
# modify subject of verification email in templates
|
||||
conn.execute(
|
||||
"update templates set subject='Confirm US Notify registration' "
|
||||
"where name = 'Notify email verification code'"
|
||||
text(
|
||||
"UPDATE templates SET subject='Confirm US Notify registration' WHERE name = 'Notify email verification code'"
|
||||
)
|
||||
)
|
||||
|
||||
# modify subject of verification email in templates_history
|
||||
conn.execute(
|
||||
"update templates_history set subject='Confirm US Notify registration' "
|
||||
"where name = 'Notify email verification code'"
|
||||
text(
|
||||
"UPDATE templates_history SET subject='Confirm US Notify registration' WHERE name = 'Notify email verification code'"
|
||||
)
|
||||
)
|
||||
|
||||
val = """Hi ((name)),\n\nTo complete your registration for US Notify please click the link below\n\n((url))"""
|
||||
|
||||
@@ -8,6 +8,7 @@ Create Date: 2023-05-23 10:03:10.485368
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = "0395_remove_intl_letters_perm"
|
||||
down_revision = "0394_remove_contact_list"
|
||||
@@ -21,7 +22,7 @@ def upgrade():
|
||||
"""
|
||||
|
||||
conn = op.get_bind()
|
||||
conn.execute(sql)
|
||||
conn.execute(text(sql))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
Reference in New Issue
Block a user