mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
merge from main
This commit is contained in:
@@ -15,17 +15,11 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
op.create_table('provider_rates',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('valid_from', sa.DateTime(), nullable=False),
|
||||
sa.Column('provider', sa.Enum('mmg', 'twilio', 'firetext', 'ses', 'sns', name='providers'), nullable=False),
|
||||
sa.Column('rate', sa.Numeric(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
op.create_table('provider_statistics',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('day', sa.Date(), nullable=False),
|
||||
sa.Column('provider', sa.Enum('mmg', 'twilio', 'firetext', 'ses', 'sns', name='providers'), nullable=False),
|
||||
sa.Column('provider', sa.Enum('ses', 'sns', name='providers'), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('unit_count', sa.BigInteger(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
@@ -37,4 +31,3 @@ def upgrade():
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_provider_statistics_service_id'), table_name='provider_statistics')
|
||||
op.drop_table('provider_statistics')
|
||||
op.drop_table('provider_rates')
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2016-05-05 09:14:29.328841
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0011_ad_provider_details'
|
||||
down_revision = '0010_events_table'
|
||||
|
||||
@@ -16,6 +18,7 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('provider_details',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
@@ -27,42 +30,23 @@ def upgrade():
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
op.add_column('provider_rates', sa.Column('provider_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.create_index(op.f('ix_provider_rates_provider_id'), 'provider_rates', ['provider_id'], unique=False)
|
||||
op.create_foreign_key("provider_rate_to_provider_fk", 'provider_rates', 'provider_details', ['provider_id'], ['id'])
|
||||
op.add_column('provider_statistics', sa.Column('provider_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.create_index(op.f('ix_provider_statistics_provider_id'), 'provider_statistics', ['provider_id'], unique=False)
|
||||
op.create_foreign_key('provider_stats_to_provider_fk', 'provider_statistics', 'provider_details', ['provider_id'], ['id'])
|
||||
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values ('{}', 'MMG', 'mmg', 10, 'sms', true)".format(str(uuid.uuid4()))
|
||||
conn = op.get_bind()
|
||||
|
||||
input_params = {
|
||||
"id": uuid.uuid4()
|
||||
}
|
||||
conn.execute(
|
||||
text("INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values (:id, 'AWS SES', 'ses', 10, 'email', true)"), input_params
|
||||
)
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values ('{}', 'Firetext', 'firetext', 20, 'sms', true)".format(str(uuid.uuid4()))
|
||||
)
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values ('{}', 'AWS SES', 'ses', 10, 'email', true)".format(str(uuid.uuid4()))
|
||||
)
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values ('{}', 'AWS SNS', 'sns', 10, 'sms', true)".format(str(uuid.uuid4()))
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider_id = (select id from provider_details where identifier = 'mmg') where provider = 'mmg'"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider_id = (select id from provider_details where identifier = 'firetext') where provider = 'firetext'"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider_id = (select id from provider_details where identifier = 'ses') where provider = 'ses'"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider_id = (select id from provider_details where identifier = 'sns') where provider = 'sns'"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider_id = (select id from provider_details where identifier = 'mmg') where provider = 'mmg'"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider_id = (select id from provider_details where identifier = 'firetext') where provider = 'firetext'"
|
||||
input_params = {
|
||||
"id": uuid.uuid4()
|
||||
}
|
||||
conn.execute(
|
||||
text("INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values (:id, 'AWS SNS', 'sns', 10, 'sms', true)"), input_params
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider_id = (select id from provider_details where identifier = 'ses') where provider = 'ses'"
|
||||
@@ -71,12 +55,10 @@ def upgrade():
|
||||
"UPDATE provider_statistics set provider_id = (select id from provider_details where identifier = 'sns') where provider = 'sns'"
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
op.drop_index(op.f('ix_provider_statistics_provider_id'), table_name='provider_statistics')
|
||||
op.drop_column('provider_statistics', 'provider_id')
|
||||
op.drop_index(op.f('ix_provider_rates_provider_id'), table_name='provider_rates')
|
||||
op.drop_column('provider_rates', 'provider_id')
|
||||
|
||||
op.drop_table('provider_details')
|
||||
op.execute('drop type notification_type')
|
||||
|
||||
@@ -18,10 +18,6 @@ from sqlalchemy.dialects.postgresql import ENUM
|
||||
|
||||
def upgrade():
|
||||
|
||||
op.alter_column('provider_rates', 'provider_id',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=False)
|
||||
op.drop_column('provider_rates', 'provider')
|
||||
op.alter_column('provider_statistics', 'provider_id',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=False)
|
||||
@@ -31,38 +27,15 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
|
||||
provider_enum = ENUM('loadtesting', 'firetext', 'mmg', 'ses', 'twilio', name='providers', create_type=True)
|
||||
provider_enum = ENUM('loadtesting', 'ses', name='providers', create_type=True)
|
||||
provider_enum.create(op.get_bind(), checkfirst=False)
|
||||
|
||||
op.add_column('provider_statistics', sa.Column('provider', provider_enum, autoincrement=False, nullable=True))
|
||||
op.alter_column('provider_statistics', 'provider_id',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=True)
|
||||
op.add_column('provider_rates', sa.Column('provider', provider_enum, autoincrement=False, nullable=True))
|
||||
op.alter_column('provider_rates', 'provider_id',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=True)
|
||||
|
||||
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider = 'mmg' where provider_id = (select id from provider_details where identifier = 'mmg')"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider = 'firetext' where provider_id = (select id from provider_details where identifier = 'firetext')"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider = 'ses' where provider_id = (select id from provider_details where identifier = 'ses')"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_rates set provider = 'loadtesting' where provider_id = (select id from provider_details where identifier = 'loadtesting')"
|
||||
)
|
||||
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider = 'mmg' where provider_id = (select id from provider_details where identifier = 'mmg')"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider = 'firetext' where provider_id = (select id from provider_details where identifier = 'firetext')"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider = 'ses' where provider_id = (select id from provider_details where identifier = 'ses')"
|
||||
)
|
||||
@@ -70,11 +43,6 @@ def downgrade():
|
||||
"UPDATE provider_statistics set provider = 'loadtesting' where provider_id = (select id from provider_details where identifier = 'loadtesting')"
|
||||
)
|
||||
|
||||
|
||||
op.alter_column('provider_rates', 'provider',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=False)
|
||||
|
||||
op.alter_column('provider_statistics', 'provider',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=False)
|
||||
@@ -1,27 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0013_add_loadtest_client
|
||||
Revises: 0012_complete_provider_details
|
||||
Create Date: 2016-05-05 09:14:29.328841
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0013_add_loadtest_client'
|
||||
down_revision = '0012_complete_provider_details'
|
||||
|
||||
import uuid
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values ('{}', 'Loadtesting', 'loadtesting', 30, 'sms', true)".format(str(uuid.uuid4()))
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('provider_details')
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0014_add_template_version
|
||||
Revises: 0013_add_loadtest_client
|
||||
Revises: 0012_complete_provider_details
|
||||
Create Date: 2016-05-11 16:00:51.478012
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0014_add_template_version'
|
||||
down_revision = '0013_add_loadtest_client'
|
||||
down_revision = '0012_complete_provider_details'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2016-05-23 15:05:25.109346
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0021_add_delivered_failed_counts'
|
||||
down_revision = '0020_template_history_fix'
|
||||
|
||||
@@ -21,19 +23,21 @@ def upgrade():
|
||||
conn = op.get_bind()
|
||||
results = conn.execute("select distinct job_id from notifications")
|
||||
res = results.fetchall()
|
||||
|
||||
for x in res:
|
||||
if x.job_id:
|
||||
op.execute("update jobs set notifications_delivered = ("
|
||||
"select count(status) from notifications where status = 'delivered' and job_id = '{}' "
|
||||
input_params = {
|
||||
"job_id": x.job_id
|
||||
}
|
||||
conn.execute(text("update jobs set notifications_delivered = ("
|
||||
"select count(status) from notifications where status = 'delivered' and job_id = :job_id "
|
||||
"group by job_id)"
|
||||
"where jobs.id = '{}'".format(x.job_id, x.job_id))
|
||||
"where jobs.id = :job_id"), input_params)
|
||||
|
||||
op.execute("update jobs set notifications_failed = ("
|
||||
conn.execute(text("update jobs set notifications_failed = ("
|
||||
"select count(status) from notifications "
|
||||
"where status in ('failed','technical-failure', 'temporary-failure', 'permanent-failure') "
|
||||
"and job_id = '{}' group by job_id)"
|
||||
"where jobs.id = '{}'".format(x.job_id, x.job_id))
|
||||
"and job_id = :job_id group by job_id)"
|
||||
"where jobs.id = :job_id"), input_params)
|
||||
op.execute("update jobs set notifications_delivered = 0 where notifications_delivered is null")
|
||||
op.execute("update jobs set notifications_failed = 0 where notifications_failed is null")
|
||||
op.alter_column('jobs', 'notifications_delivered', nullable=False)
|
||||
|
||||
@@ -10,6 +10,7 @@ Create Date: 2016-06-01 14:17:01.963181
|
||||
from datetime import datetime
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.hashing import hashpw
|
||||
import uuid
|
||||
@@ -23,42 +24,45 @@ service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||
|
||||
def upgrade():
|
||||
password = hashpw(str(uuid.uuid4()))
|
||||
op.get_bind()
|
||||
conn = op.get_bind()
|
||||
user_insert = """INSERT INTO users (id, name, email_address, created_at, failed_login_count, _password, mobile_number, state, platform_admin)
|
||||
VALUES ('{}', 'Notify service user', 'testsender@dispostable.com', '{}', 0,'{}', '+441234123412', 'active', False)
|
||||
VALUES (:user_id, 'Notify service user', 'testsender@dispostable.com', :time_now, 0,:password, '+441234123412', 'active', False)
|
||||
"""
|
||||
op.execute(user_insert.format(user_id, datetime.utcnow(), password))
|
||||
conn.execute(text(user_insert), 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 ('{}', 'Notify service', '{}', True, 1000, False, False, 'testsender@dispostable.com',
|
||||
'{}', 'testsender@dispostable.com', 1)
|
||||
VALUES (:service_id, 'Notify service', :time_now, True, 1000, False, False, 'testsender@dispostable.com',
|
||||
:user_id, 'testsender@dispostable.com', 1)
|
||||
|
||||
"""
|
||||
op.execute(service_history_insert.format(service_id, datetime.utcnow(), user_id))
|
||||
conn.execute(text(service_history_insert), 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 ('{}', 'Notify service', '{}', True, 1000, False, False, 'testsender@dispostable.com',
|
||||
'{}', 'testsender@dispostable.com', 1)
|
||||
VALUES (:service_id, 'Notify service', :time_now, True, 1000, False, False, 'testsender@dispostable.com',
|
||||
:user_id, 'testsender@dispostable.com', 1)
|
||||
"""
|
||||
op.execute(service_insert.format(service_id, datetime.utcnow(), user_id))
|
||||
user_to_service_insert = """INSERT INTO user_to_service (user_id, service_id) VALUES ('{}', '{}')"""
|
||||
op.execute(user_to_service_insert.format(user_id, service_id))
|
||||
conn.execute(text(service_insert), 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)
|
||||
|
||||
template_history_insert = """INSERT INTO templates_history (id, name, template_type, created_at,
|
||||
content, archived, service_id,
|
||||
subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
VALUES (:template_id, :template_name, :template_type, :time_now,
|
||||
:content, False, :service_id, :subject, :user_id, 1)
|
||||
"""
|
||||
template_insert = """INSERT INTO templates (id, name, template_type, created_at,
|
||||
content, archived, service_id, subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
VALUES (:template_id, :template_name, :template_type, :time_now,
|
||||
:content, False, :service_id, :subject, :user_id, 1)
|
||||
"""
|
||||
email_verification_content = \
|
||||
"""Hi ((name)),\n\nTo complete your registration for GOV.UK Notify please click the link below\n\n((url))"""
|
||||
op.execute(template_history_insert.format(uuid.uuid4(), 'Notify email verification code', 'email',
|
||||
datetime.utcnow(), email_verification_content, service_id,
|
||||
'Confirm GOV.UK Notify registration', user_id))
|
||||
op.execute(template_insert.format('ece42649-22a8-4d06-b87f-d52d5d3f0a27', 'Notify email verification code', 'email',
|
||||
datetime.utcnow(), email_verification_content, service_id,
|
||||
'Confirm GOV.UK Notify registration', user_id))
|
||||
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)
|
||||
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)
|
||||
|
||||
invitation_subject = "((user_name)) has invited you to collaborate on ((service_name)) on GOV.UK Notify"
|
||||
invitation_content = """((user_name)) has invited you to collaborate on ((service_name)) on GOV.UK Notify.\n\n
|
||||
@@ -66,19 +70,23 @@ def upgrade():
|
||||
Click this link to create an account on GOV.UK Notify:\n((url))\n\n
|
||||
This invitation will stop working at midnight tomorrow. This is to keep ((service_name)) secure.
|
||||
"""
|
||||
op.execute(template_history_insert.format('4f46df42-f795-4cc4-83bb-65ca312f49cc', 'Notify invitation email',
|
||||
'email', datetime.utcnow(), invitation_content, service_id,
|
||||
invitation_subject, user_id))
|
||||
op.execute(template_insert.format('4f46df42-f795-4cc4-83bb-65ca312f49cc', 'Notify invitation email',
|
||||
'email', datetime.utcnow(), invitation_content, service_id,
|
||||
invitation_subject, user_id))
|
||||
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)
|
||||
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)
|
||||
|
||||
sms_code_content = '((verify_code)) is your US Notify authentication code'
|
||||
op.execute(template_history_insert.format('36fb0730-6259-4da1-8a80-c8de22ad4246', 'Notify SMS verify code',
|
||||
'sms', datetime.utcnow(), sms_code_content, service_id, None, user_id))
|
||||
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)
|
||||
|
||||
op.execute(template_insert.format('36fb0730-6259-4da1-8a80-c8de22ad4246', 'Notify SMS verify code',
|
||||
'sms', datetime.utcnow(), sms_code_content, service_id, None, 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)
|
||||
|
||||
password_reset_content = "Hi ((user_name)),\n\n" \
|
||||
"We received a request to reset your password on GOV.UK Notify.\n\n" \
|
||||
@@ -87,20 +95,23 @@ def upgrade():
|
||||
"To reset your password, click this link:\n\n" \
|
||||
"((url))"
|
||||
|
||||
op.execute(template_history_insert.format('474e9242-823b-4f99-813d-ed392e7f1201', 'Notify password reset email',
|
||||
'email', datetime.utcnow(), password_reset_content, service_id,
|
||||
'Reset your GOV.UK Notify password', user_id))
|
||||
op.execute(template_insert.format('474e9242-823b-4f99-813d-ed392e7f1201', 'Notify password reset email',
|
||||
'email', datetime.utcnow(), password_reset_content, service_id,
|
||||
'Reset your GOV.UK Notify password', user_id))
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.get_bind()
|
||||
op.execute("delete from templates where service_id = '{}'".format(service_id))
|
||||
op.execute("delete from templates_history where service_id = '{}'".format(service_id))
|
||||
op.execute("delete from user_to_service where service_id = '{}'".format(service_id))
|
||||
op.execute("delete from services_history where id = '{}'".format(service_id))
|
||||
op.execute("delete from services where id = '{}'".format(service_id))
|
||||
op.execute("delete from users where id = '{}'".format(user_id))
|
||||
conn = op.get_bind()
|
||||
conn.execute(text("delete from templates where service_id = :service_id"), service_id=service_id)
|
||||
conn.execute(text("delete from templates_history where service_id = :service_id"), service_id=service_id)
|
||||
conn.execute(text("delete from user_to_service where service_id = :service_id"), service_id=service_id)
|
||||
conn.execute(text("delete from services_history where id = :service_id"), service_id=service_id)
|
||||
conn.execute(text("delete from services where id = :service_id"), service_id=service_id)
|
||||
conn.execute(text("delete from users where id = :service_id"), service_id=service_id)
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0027_update_provider_rates
|
||||
Revises: 0026_rename_notify_service
|
||||
Create Date: 2016-06-08 01:00:00.000000
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0027_update_provider_rates'
|
||||
down_revision = '0026_rename_notify_service'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.get_bind()
|
||||
op.execute((
|
||||
"INSERT INTO provider_rates (id, valid_from, rate, provider_id) VALUES ('{}', '{}', 1.8, "
|
||||
"(SELECT id FROM provider_details WHERE identifier = 'mmg'))").format(uuid.uuid4(), datetime.utcnow()))
|
||||
op.execute((
|
||||
"INSERT INTO provider_rates (id, valid_from, rate, provider_id) VALUES ('{}', '{}', 2.5, "
|
||||
"(SELECT id FROM provider_details WHERE identifier = 'firetext'))").format(uuid.uuid4(), datetime.utcnow()))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.get_bind()
|
||||
op.execute("DELETE FROM provider_rates")
|
||||
### end Alembic commands ###
|
||||
@@ -1,7 +1,7 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0028_fix_reg_template_history
|
||||
Revises: 0027_update_provider_rates
|
||||
Revises: 0026_rename_notify_service
|
||||
Create Date: 2016-06-13 11:04:15.888017
|
||||
|
||||
"""
|
||||
@@ -9,8 +9,10 @@ Create Date: 2016-06-13 11:04:15.888017
|
||||
# revision identifiers, used by Alembic.
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0028_fix_reg_template_history'
|
||||
down_revision = '0027_update_provider_rates'
|
||||
down_revision = '0026_rename_notify_service'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@@ -25,14 +27,24 @@ def upgrade():
|
||||
template_history_insert = """INSERT INTO templates_history (id, name, template_type, created_at,
|
||||
content, archived, service_id,
|
||||
subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
VALUES (:id, :name, :type, :time_now, :content, False, :service_id, :subject, :user_id, 1)
|
||||
"""
|
||||
email_verification_content = \
|
||||
"""Hi ((name)),\n\nTo complete your registration for GOV.UK Notify please click the link below\n\n((url))"""
|
||||
op.execute(template_history_insert.format('ece42649-22a8-4d06-b87f-d52d5d3f0a27',
|
||||
'Notify email verification code', 'email',
|
||||
datetime.utcnow(), email_verification_content, service_id,
|
||||
'Confirm GOV.UK Notify registration', user_id))
|
||||
|
||||
input_params = {
|
||||
"id": 'ece42649-22a8-4d06-b87f-d52d5d3f0a27',
|
||||
"name": 'Notify email verification code',
|
||||
"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 = op.get_bind()
|
||||
conn.execute(text(template_history_insert), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2016-06-13 15:15:34.035984
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0029_fix_email_from'
|
||||
down_revision = '0028_fix_reg_template_history'
|
||||
|
||||
@@ -14,10 +16,15 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.get_bind()
|
||||
op.execute("update services set email_from = 'testsender' where id = '{}'".format(service_id))
|
||||
op.execute("update services_history set email_from = 'testsender' where id = '{}'".format(service_id))
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"service_id": service_id
|
||||
}
|
||||
conn.execute(text("update services set email_from = 'testsender' where id = :service_id"), input_params)
|
||||
conn.execute(text("update services_history set email_from = 'testsender' where id = :service_id"), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2016-07-06 13:28:48.381278
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0039_fix_notifications'
|
||||
down_revision = '0038_test_api_key_type'
|
||||
|
||||
@@ -26,28 +28,32 @@ def upgrade():
|
||||
res = results.fetchall()
|
||||
|
||||
for x in res:
|
||||
print(' in loop {} {}'.format(x.notification_type, x.created_at))
|
||||
created = x.created_at.strftime("%Y-%m-%d")
|
||||
input_params = {
|
||||
"created": created,
|
||||
"service_id": x.service_id
|
||||
}
|
||||
if x.notification_type == 'email' and x.status == 'delivered':
|
||||
sql = "update notification_statistics set emails_requested = emails_requested + 1, " \
|
||||
"emails_delivered = emails_delivered + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
|
||||
sql = text("update notification_statistics set emails_requested = emails_requested + 1, " \
|
||||
"emails_delivered = emails_delivered + 1 where day = date(:created) and service_id = :service_id")
|
||||
if x.notification_type == 'sms' and x.status == 'delivered':
|
||||
sql = "update notification_statistics set sms_requested = sms_requested + 1, " \
|
||||
"sms_delivered = sms_delivered + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
|
||||
sql = text("update notification_statistics set sms_requested = sms_requested + 1, " \
|
||||
"sms_delivered = sms_delivered + 1 where day = date(:created) and service_id = :service_id")
|
||||
if x.notification_type == 'email' and x.status in ['technical-failure', 'temporary-failure', 'permanent-failure']:
|
||||
sql = "update notification_statistics set emails_requested = emails_requested + 1, " \
|
||||
"emails_failed = emails_failed + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
|
||||
sql = text("update notification_statistics set emails_requested = emails_requested + 1, " \
|
||||
"emails_failed = emails_failed + 1 where day = date(:created) and service_id = :service_id")
|
||||
if x.notification_type == 'sms' and x.status in ['technical-failure', 'temporary-failure', 'permanent-failure']:
|
||||
sql = "update notification_statistics set sms_requested = sms_requested + 1, " \
|
||||
"sms_failed = sms_failed + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
|
||||
sql = text("update notification_statistics set sms_requested = sms_requested + 1, " \
|
||||
"sms_failed = sms_failed + 1 where day = date(:created) and service_id = :service_id")
|
||||
if x.notification_type == 'email' and x.status in ['created', 'sending', 'pending']:
|
||||
sql = "update notification_statistics set emails_requested = emails_requested + 1 " \
|
||||
" where day = date('{}') and service_id = '{}'".format(created, x.service_id)
|
||||
sql = text("update notification_statistics set emails_requested = emails_requested + 1 " \
|
||||
" where day = date(:created) and service_id = :service_id")
|
||||
if x.notification_type == 'sms' and x.status in ['created', 'sending', 'pending']:
|
||||
sql = "update notification_statistics set sms_requested = sms_requested + 1 " \
|
||||
" where day = date('{}') and service_id = '{}'".format(created, x.service_id)
|
||||
sql = text("update notification_statistics set sms_requested = sms_requested + 1 " \
|
||||
" where day = date(:created) and service_id = :service_id")
|
||||
print(sql)
|
||||
conn.execute(sql)
|
||||
conn.execute(sql, input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
"""mmg rates now set to 1.65 pence per sms
|
||||
|
||||
Revision ID: 0040_adjust_mmg_provider_rate
|
||||
Revises: 0039_fix_notifications
|
||||
Create Date: 2016-07-06 15:19:23.124212
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0040_adjust_mmg_provider_rate'
|
||||
down_revision = '0039_fix_notifications'
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
sa.sql.text(("INSERT INTO provider_rates (id, valid_from, rate, provider_id) "
|
||||
"VALUES (:id, :valid_from, :rate, (SELECT id FROM provider_details WHERE identifier = 'mmg'))")),
|
||||
id=uuid.uuid4(),
|
||||
valid_from=datetime(2016, 7, 1),
|
||||
rate=1.65
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute(("DELETE FROM provider_rates "
|
||||
"WHERE provider_id = (SELECT id FROM provider_details WHERE identifier = 'mmg') "
|
||||
"AND rate = 1.65"))
|
||||
### end Alembic commands ###
|
||||
@@ -1,66 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0041_email_template
|
||||
Revises: 0040_adjust_mmg_provider_rate
|
||||
Create Date: 2016-07-07 16:02:06.241769
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from datetime import datetime
|
||||
|
||||
revision = '0041_email_template'
|
||||
down_revision = '0040_adjust_mmg_provider_rate'
|
||||
|
||||
from alembic import op
|
||||
|
||||
user_id = '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
||||
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||
|
||||
|
||||
def upgrade():
|
||||
template_history_insert = """INSERT INTO templates_history (id, name, template_type, created_at,
|
||||
content, archived, service_id,
|
||||
subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
"""
|
||||
template_insert = """INSERT INTO templates (id, name, template_type, created_at,
|
||||
content, archived, service_id, subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
"""
|
||||
content = """You already have a GOV.UK Notify account with this email address.
|
||||
|
||||
Sign in here: ((signin_url))
|
||||
|
||||
If you’ve forgotten your password, you can reset it here: ((forgot_password_url))
|
||||
|
||||
|
||||
If you didn’t try to register for a GOV.UK Notify account recently, please let us know here: ((feedback_url))"""
|
||||
|
||||
op.get_bind()
|
||||
op.execute(template_history_insert.format('0880fbb1-a0c6-46f0-9a8e-36c986381ceb',
|
||||
'Your GOV.UK Notify account', 'email',
|
||||
datetime.utcnow(), content, service_id,
|
||||
'Your GOV.UK Notify account', user_id))
|
||||
op.execute(
|
||||
template_insert.format('0880fbb1-a0c6-46f0-9a8e-36c986381ceb', 'Your GOV.UK Notify account', 'email',
|
||||
datetime.utcnow(), content, service_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():
|
||||
op.execute("delete from notifications where template_id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
||||
op.execute("delete from jobs where template_id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
||||
op.execute("delete from template_statistics where template_id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
||||
op.execute("delete from templates_history where id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
||||
op.execute("delete from templates where id = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'")
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0042_notification_history
|
||||
Revises: 0041_email_template
|
||||
Revises: 0039_fix_notifications
|
||||
Create Date: 2016-07-07 13:15:35.503107
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0042_notification_history'
|
||||
down_revision = '0041_email_template'
|
||||
down_revision = '0039_fix_notifications'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2016-08-02 16:36:42.455838
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text, bindparam
|
||||
|
||||
revision = '0045_billable_units'
|
||||
down_revision = '0044_jobs_to_notification_hist'
|
||||
|
||||
@@ -36,11 +38,11 @@ def upgrade():
|
||||
SELECT id FROM services_history WHERE id not in (select id from services_history where research_mode)
|
||||
''')
|
||||
# set to 'null' if there are no billable services so we don't get a syntax error in the update statement
|
||||
service_ids = ','.join("'{}'".format(service.id) for service in billable_services) or 'null'
|
||||
service_ids = ','.join(f"{service.id}" for service in billable_services) or 'null'
|
||||
|
||||
|
||||
update_statement = '''
|
||||
UPDATE {}
|
||||
update_statement_n = '''
|
||||
UPDATE notifications
|
||||
SET billable_units = (
|
||||
CASE
|
||||
WHEN content_char_count <= 160 THEN 1
|
||||
@@ -48,13 +50,29 @@ def upgrade():
|
||||
END
|
||||
)
|
||||
WHERE content_char_count is not null
|
||||
AND service_id in ({})
|
||||
AND service_id in (:service_ids)
|
||||
AND notification_type = 'sms'
|
||||
'''
|
||||
|
||||
update_statement_nh = '''
|
||||
UPDATE notification_history
|
||||
SET billable_units = (
|
||||
CASE
|
||||
WHEN content_char_count <= 160 THEN 1
|
||||
ELSE ceil(content_char_count::float / 153::float)
|
||||
END
|
||||
)
|
||||
WHERE content_char_count is not null
|
||||
AND service_id in (:service_ids)
|
||||
AND notification_type = 'sms'
|
||||
'''
|
||||
|
||||
conn = op.get_bind()
|
||||
conn.execute(update_statement.format('notifications', service_ids))
|
||||
conn.execute(update_statement.format('notification_history', service_ids))
|
||||
|
||||
query = text(update_statement_n).bindparams(bindparam("service_ids", expanding=False))
|
||||
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)
|
||||
op.drop_column('notifications', 'content_char_count')
|
||||
op.drop_column('notification_history', 'content_char_count')
|
||||
|
||||
@@ -82,20 +100,30 @@ def downgrade():
|
||||
SELECT id FROM services_history WHERE id not in (select id from services_history where research_mode)
|
||||
''')
|
||||
# set to 'null' if there are no billable services so we don't get a syntax error in the update statement
|
||||
service_ids = ','.join("'{}'".format(service.id) for service in billable_services) or 'null'
|
||||
service_ids = ','.join(f"{service.id}" for service in billable_services) or 'null'
|
||||
|
||||
# caveats:
|
||||
# only approximates character counts - billable * 153 to get at least a decent ballpark
|
||||
# research mode messages assumed to be one message length
|
||||
update_statement = '''
|
||||
UPDATE {}
|
||||
update_statement_n = '''
|
||||
UPDATE notifications
|
||||
SET content_char_count = GREATEST(billable_units, 1) * 150
|
||||
WHERE service_id in ({})
|
||||
WHERE service_id in (:service_ids)
|
||||
AND notification_type = 'sms'
|
||||
'''
|
||||
|
||||
update_statement_nh = '''
|
||||
UPDATE notification_history
|
||||
SET content_char_count = GREATEST(billable_units, 1) * 150
|
||||
WHERE service_id in (:service_ids)
|
||||
AND notification_type = 'sms'
|
||||
'''
|
||||
|
||||
conn = op.get_bind()
|
||||
conn.execute(update_statement.format('notifications', service_ids))
|
||||
conn.execute(update_statement.format('notification_history', service_ids))
|
||||
query = text(update_statement_n).bindparams(bindparam("service_ids", expanding=False))
|
||||
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)
|
||||
|
||||
op.drop_column('notifications', 'billable_units')
|
||||
op.drop_column('notification_history', 'billable_units')
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0047_ukvi_spelling
|
||||
Revises: 0046_organisations_and_branding
|
||||
Create Date: 2016-08-22 16:06:32.981723
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0047_ukvi_spelling'
|
||||
down_revision = '0046_organisations_and_branding'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
UPDATE organisation
|
||||
SET name = 'UK Visas & Immigration'
|
||||
WHERE id = '9d25d02d-2915-4e98-874b-974e123e8536'
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
UPDATE organisation
|
||||
SET name = 'UK Visas and Immigration'
|
||||
WHERE id = '9d25d02d-2915-4e98-874b-974e123e8536'
|
||||
""")
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0048_job_scheduled_time
|
||||
Revises: 0047_ukvi_spelling
|
||||
Revises: 0046_organisations_and_branding
|
||||
Create Date: 2016-08-24 13:21:51.744526
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0048_job_scheduled_time'
|
||||
down_revision = '0047_ukvi_spelling'
|
||||
down_revision = '0046_organisations_and_branding'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0057_change_email_template
|
||||
Revises: 0056_minor_updates
|
||||
Create Date: 2016-10-11 09:24:45.669018
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
|
||||
revision = '0057_change_email_template'
|
||||
down_revision = '0056_minor_updates'
|
||||
|
||||
user_id = '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
||||
service_id = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||
template_id = 'eb4d9930-87ab-4aef-9bce-786762687884'
|
||||
|
||||
|
||||
def upgrade():
|
||||
template_history_insert = """INSERT INTO templates_history (id, name, template_type, created_at,
|
||||
content, archived, service_id,
|
||||
subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
"""
|
||||
template_insert = """INSERT INTO templates (id, name, template_type, created_at,
|
||||
content, archived, service_id, subject, created_by_id, version)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1)
|
||||
"""
|
||||
template_content = \
|
||||
"""Hi ((name)),\n\nClick this link to confirm your new email address:
|
||||
\n\n((url))
|
||||
\n\nIf you didn’t try to change the email address for your GOV.UK Notify account, let us know here:
|
||||
\n\n((feedback_url))"""
|
||||
|
||||
template_name = 'Confirm new email address'
|
||||
op.execute(template_history_insert.format(template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(), template_content,
|
||||
service_id,
|
||||
template_name, user_id))
|
||||
op.execute(template_insert.format(template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
service_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():
|
||||
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 where id = '{}'".format(template_id))
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0058_add_letters_flag
|
||||
Revises: 0057_change_email_template
|
||||
Revises: 0056_minor_updates
|
||||
Create Date: 2016-10-25 17:37:27.660723
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0058_add_letters_flag'
|
||||
down_revision = '0057_change_email_template'
|
||||
down_revision = '0056_minor_updates'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0066_add_dvla_provider
|
||||
Revises: 0065_users_current_session_id
|
||||
Create Date: 2017-03-02 10:32:28.984947
|
||||
|
||||
"""
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
revision = '0066_add_dvla_provider'
|
||||
down_revision = '0065_users_current_session_id'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
provider_id = str(uuid.uuid4())
|
||||
op.execute(
|
||||
"INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active, version) values ('{}', 'DVLA', 'dvla', 50, 'letter', true, 1)".format(provider_id)
|
||||
)
|
||||
op.execute(
|
||||
"INSERT INTO provider_details_history (id, display_name, identifier, priority, notification_type, active, version) values ('{}', 'DVLA', 'dvla', 50, 'letter', true, 1)".format(provider_id)
|
||||
)
|
||||
op.execute("INSERT INTO provider_rates (id, valid_from, rate, provider_id) VALUES ('{}', '{}', 1.0, '{}')".format(uuid.uuid4(), datetime.utcnow(), provider_id))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("DELETE FROM provider_rates where provider_id = (SELECT id from provider_details where display_name='DVLA')")
|
||||
op.execute("DELETE FROM provider_details_history where display_name = 'DVLA'")
|
||||
op.execute("DELETE FROM provider_details where display_name = 'DVLA'")
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0067_service_contact_block
|
||||
Revises: 0066_add_dvla_provider
|
||||
Revises: 0065_users_current_session_id
|
||||
Create Date: 2017-02-28 11:23:40.299110
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0067_service_contact_block'
|
||||
down_revision = '0066_add_dvla_provider'
|
||||
down_revision = '0065_users_current_session_id'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0074_update_sms_rate
|
||||
Revises: 0073_add_international_sms_flag
|
||||
Create Date: 2017-04-24 12:10:02.116278
|
||||
|
||||
"""
|
||||
|
||||
import uuid
|
||||
|
||||
revision = '0074_update_sms_rate'
|
||||
down_revision = '0073_add_international_sms_flag'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.get_bind()
|
||||
op.execute("INSERT INTO provider_rates (id, valid_from, rate, provider_id) "
|
||||
"VALUES ('{}', '2017-04-01 00:00:00', 1.58, "
|
||||
"(SELECT id FROM provider_details WHERE identifier = 'mmg'))".format(uuid.uuid4())
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.get_bind()
|
||||
op.execute("DELETE FROM provider_rates where valid_from = '2017-04-01 00:00:00' "
|
||||
"and provider_id = (SELECT id FROM provider_details WHERE identifier = 'mmg')")
|
||||
@@ -1,7 +1,7 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0075_create_rates_table
|
||||
Revises: 0074_update_sms_rate
|
||||
Revises: 0073_add_international_sms_flag
|
||||
Create Date: 2017-04-24 15:12:18.907629
|
||||
|
||||
"""
|
||||
@@ -9,8 +9,10 @@ Create Date: 2017-04-24 15:12:18.907629
|
||||
# revision identifiers, used by Alembic.
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0075_create_rates_table'
|
||||
down_revision = '0074_update_sms_rate'
|
||||
down_revision = '0073_add_international_sms_flag'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
@@ -28,11 +30,17 @@ def upgrade():
|
||||
|
||||
op.create_index(op.f('ix_rates_notification_type'), 'rates', ['notification_type'], unique=False)
|
||||
|
||||
op.get_bind()
|
||||
op.execute("INSERT INTO rates(id, valid_from, rate, notification_type) "
|
||||
"VALUES('{}', '2016-05-18 00:00:00', 1.65, 'sms')".format(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 = op.get_bind()
|
||||
input_params = {
|
||||
"id": 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():
|
||||
|
||||
@@ -33,28 +33,28 @@ new_type = sa.Enum(*new_options, name=enum_name)
|
||||
|
||||
alter_str = 'ALTER TABLE {table} ALTER COLUMN status TYPE {enum} USING status::text::notify_status_type '
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute('ALTER TYPE {enum} RENAME TO {tmp_name}'.format(enum=enum_name, tmp_name=tmp_name))
|
||||
op.execute('ALTER TYPE notify_status_type RENAME TO tmp_notify_status_type')
|
||||
|
||||
new_type.create(op.get_bind())
|
||||
op.execute(alter_str.format(table='notifications', enum=enum_name))
|
||||
op.execute(alter_str.format(table='notification_history', enum=enum_name))
|
||||
op.execute('ALTER TABLE notifications ALTER COLUMN status TYPE notify_status_type USING status::text::notify_status_type')
|
||||
op.execute(
|
||||
'ALTER TABLE notification_history ALTER COLUMN status TYPE notify_status_type USING status::text::notify_status_type')
|
||||
|
||||
op.execute('DROP TYPE ' + tmp_name)
|
||||
op.execute('DROP TYPE tmp_notify_status_type')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute('ALTER TYPE {enum} RENAME TO {tmp_name}'.format(enum=enum_name, tmp_name=tmp_name))
|
||||
op.execute('ALTER TYPE notify_status_type RENAME TO tmp_notify_status_type')
|
||||
|
||||
# Convert 'sent' template into 'sending'
|
||||
update_str = "UPDATE {table} SET status='sending' where status='sent'"
|
||||
|
||||
op.execute(update_str.format(table='notifications'))
|
||||
op.execute(update_str.format(table='notification_history'))
|
||||
op.execute("UPDATE notifications SET status='sending' where status='sent'")
|
||||
op.execute("UPDATE notification_history SET status='sending' where status='sent'")
|
||||
|
||||
old_type.create(op.get_bind())
|
||||
|
||||
op.execute(alter_str.format(table='notifications', enum=enum_name))
|
||||
op.execute(alter_str.format(table='notification_history', enum=enum_name))
|
||||
op.execute('ALTER TABLE notifications ALTER COLUMN status TYPE notify_status_type USING status::text::notify_status_type')
|
||||
op.execute(
|
||||
'ALTER TABLE notification_history ALTER COLUMN status TYPE notify_status_type USING status::text::notify_status_type')
|
||||
|
||||
op.execute('DROP TYPE ' + tmp_name)
|
||||
op.execute('DROP TYPE tmp_notify_status_type')
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0079_update_rates
|
||||
Revises: 0078_sent_notification_status
|
||||
Create Date: 2017-05-03 12:31:20.731069
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0079_update_rates'
|
||||
down_revision = '0078_sent_notification_status'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.get_bind()
|
||||
op.execute("UPDATE RATES SET rate = 0.0158 WHERE valid_from = '2017-04-01 00:00:00'")
|
||||
op.execute("UPDATE RATES SET rate = 0.0165 WHERE valid_from = '2016-05-18 00:00:00'")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.get_bind()
|
||||
op.execute("UPDATE RATES SET rate = 1.58 WHERE valid_from = '2017-04-01 00:00:00'")
|
||||
op.execute("UPDATE RATES SET rate = 1.65 WHERE valid_from = '2016-05-18 00:00:00'")
|
||||
@@ -1,24 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0080_fix_rate_start_date
|
||||
Revises: 0079_update_rates
|
||||
Create Date: 2017-05-03 16:50:11.334116
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0080_fix_rate_start_date'
|
||||
down_revision = '0079_update_rates'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.get_bind()
|
||||
op.execute("UPDATE RATES SET valid_from = '2017-03-31 23:00:00' WHERE valid_from = '2017-04-01 00:00:00'")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.get_bind()
|
||||
op.execute("UPDATE RATES SET valid_from = '2017-03-31 23:00:00' WHERE valid_from = '2017-04-01 00:00:00'")
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0081_noti_status_as_enum
|
||||
Revises: 0080_fix_rate_start_date
|
||||
Revises: 0078_sent_notification_status
|
||||
Create Date: 2017-05-02 14:50:04.070874
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0081_noti_status_as_enum'
|
||||
down_revision = '0080_fix_rate_start_date'
|
||||
down_revision = '0078_sent_notification_status'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -13,6 +13,7 @@ from flask import current_app
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0082_add_go_live_template'
|
||||
down_revision = '0081_noti_status_as_enum'
|
||||
@@ -23,11 +24,11 @@ template_id = '618185c6-3636-49cd-b7d2-6f6f5eb3bdde'
|
||||
def upgrade():
|
||||
template_insert = """
|
||||
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 = """
|
||||
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)),
|
||||
@@ -85,47 +86,33 @@ GOV.UK Notify team
|
||||
template_name = "Automated \"You''re now live\" message"
|
||||
template_subject = '((service name)) is now live on GOV.UK Notify'
|
||||
|
||||
op.execute(
|
||||
template_history_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
input_params = {
|
||||
'template_id': template_id,
|
||||
'template_name': template_name,
|
||||
'template_type': 'email',
|
||||
'time_now': datetime.utcnow(),
|
||||
'content': template_content,
|
||||
'notify_service_id': current_app.config['NOTIFY_SERVICE_ID'],
|
||||
'subject': template_subject,
|
||||
'user_id': current_app.config['NOTIFY_USER_ID'],
|
||||
'process_type': 'normal'
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
text(template_history_insert), input_params
|
||||
)
|
||||
|
||||
op.execute(
|
||||
template_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
conn.execute(
|
||||
text(template_insert), input_params
|
||||
)
|
||||
|
||||
# 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():
|
||||
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 WHERE id = '{}'".format(template_id))
|
||||
input_params = {
|
||||
"template_id": 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)
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0091_letter_billing
|
||||
Revises: 0090_inbound_sms
|
||||
Create Date: 2017-05-31 11:43:55.744631
|
||||
|
||||
"""
|
||||
import uuid
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0091_letter_billing'
|
||||
down_revision = '0090_inbound_sms'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('letter_rates',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('valid_from', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('letter_rate_details',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('letter_rate_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('page_total', sa.Integer(), nullable=False),
|
||||
sa.Column('rate', sa.Numeric(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['letter_rate_id'], ['letter_rates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_letter_rate_details_letter_rate_id'), 'letter_rate_details', ['letter_rate_id'],
|
||||
unique=False)
|
||||
|
||||
op.get_bind()
|
||||
letter_id = uuid.uuid4()
|
||||
op.execute("insert into letter_rates(id, valid_from) values('{}', '2017-03-31 23:00:00')".format(letter_id))
|
||||
insert_details = "insert into letter_rate_details(id, letter_rate_id, page_total, rate) values('{}', '{}', {}, {})"
|
||||
op.execute(
|
||||
insert_details.format(uuid.uuid4(), letter_id, 1, 29.3))
|
||||
op.execute(
|
||||
insert_details.format(uuid.uuid4(), letter_id, 2, 32))
|
||||
op.execute(
|
||||
insert_details.format(uuid.uuid4(), letter_id, 3, 35))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.get_bind()
|
||||
op.drop_index('ix_letter_rate_details_letter_rate_id')
|
||||
op.drop_table('letter_rate_details')
|
||||
op.drop_table('letter_rates')
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0092_add_inbound_provider
|
||||
Revises: 0091_letter_billing
|
||||
Revises: 0090_inbound_sms
|
||||
Create Date: 2017-06-02 16:07:35.445423
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0092_add_inbound_provider'
|
||||
down_revision = '0091_letter_billing'
|
||||
down_revision = '0090_inbound_sms'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0093_data_gov_uk
|
||||
Revises: 0092_add_inbound_provider
|
||||
Create Date: 2017-06-05 16:15:17.744908
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0093_data_gov_uk'
|
||||
down_revision = '0092_add_inbound_provider'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
DATA_GOV_UK_ID = '123496d4-44cb-4324-8e0a-4187101f4bdc'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""INSERT INTO organisation VALUES (
|
||||
'{}',
|
||||
'',
|
||||
'data_gov_uk_x2.png',
|
||||
'data gov.uk'
|
||||
)""".format(DATA_GOV_UK_ID))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
DELETE FROM organisation WHERE "id" = '{}'
|
||||
""".format(DATA_GOV_UK_ID))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0094_job_stats_update
|
||||
Revises: 0093_data_gov_uk
|
||||
Revises: 0092_add_inbound_provider
|
||||
Create Date: 2017-06-06 14:37:30.051647
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0094_job_stats_update'
|
||||
down_revision = '0093_data_gov_uk'
|
||||
down_revision = '0092_add_inbound_provider'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2017-05-23 18:13:03.532095
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0095_migrate_existing_svc_perms'
|
||||
down_revision = '0094_job_stats_update'
|
||||
|
||||
@@ -27,13 +29,34 @@ def upgrade():
|
||||
"{2} AND id NOT IN (SELECT service_id FROM service_permissions "\
|
||||
"WHERE service_id=id AND permission='{0}')".format(permission, migration_date, flag)
|
||||
|
||||
op.execute("INSERT INTO service_permissions (service_id, permission, created_at) {}".format(get_values('sms')))
|
||||
op.execute("INSERT INTO service_permissions (service_id, permission, created_at) {}".format(get_values('email')))
|
||||
op.execute("INSERT INTO service_permissions (service_id, permission, created_at) {}".format(
|
||||
get_values_if_flag('letter', 'can_send_letters')))
|
||||
op.execute("INSERT INTO service_permissions (service_id, permission, created_at) {}".format(
|
||||
get_values_if_flag('international_sms', 'can_send_international_sms')))
|
||||
conn = op.get_bind()
|
||||
conn.execute("""
|
||||
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("""
|
||||
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("""
|
||||
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("""
|
||||
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')
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("DELETE FROM service_permissions WHERE created_at = '{}'::timestamp".format(migration_date))
|
||||
op.execute("DELETE FROM service_permissions WHERE created_at = '2017-05-26 17:30:00.000000'::timestamp")
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2017-06-05 16:15:17.744908
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0099_tfl_dar'
|
||||
down_revision = '0098_service_inbound_api'
|
||||
|
||||
@@ -18,15 +20,23 @@ TFL_DAR_ID = '1d70f564-919b-4c68-8bdf-b8520d92516e'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""INSERT INTO organisation VALUES (
|
||||
'{}',
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"tfl_dar_id": TFL_DAR_ID
|
||||
}
|
||||
conn.execute(text("""INSERT INTO organisation VALUES (
|
||||
:tfl_dar_id,
|
||||
'',
|
||||
'tfl_dar_x2.png',
|
||||
'tfl'
|
||||
)""".format(TFL_DAR_ID))
|
||||
)"""), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
DELETE FROM organisation WHERE "id" = '{}'
|
||||
""".format(TFL_DAR_ID))
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"tfl_dar_id": TFL_DAR_ID
|
||||
}
|
||||
conn.execute(text("""
|
||||
DELETE FROM organisation WHERE "id" = :tfl_dar_id
|
||||
"""), input_params)
|
||||
|
||||
@@ -7,6 +7,7 @@ Create Date: 2017-06-26 11:43:30.374723
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0101_een_logo'
|
||||
down_revision = '0100_notification_created_by'
|
||||
@@ -16,15 +17,23 @@ ENTERPRISE_EUROPE_NETWORK_ID = '89ce468b-fb29-4d5d-bd3f-d468fb6f7c36'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""INSERT INTO organisation VALUES (
|
||||
'{}',
|
||||
input_params = {
|
||||
"network_id": ENTERPRISE_EUROPE_NETWORK_ID
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(text("""INSERT INTO organisation VALUES (
|
||||
:network_id,
|
||||
'',
|
||||
'een_x2.png',
|
||||
'een'
|
||||
)""".format(ENTERPRISE_EUROPE_NETWORK_ID))
|
||||
)"""), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
DELETE FROM organisation WHERE "id" = '{}'
|
||||
""".format(ENTERPRISE_EUROPE_NETWORK_ID))
|
||||
input_params = {
|
||||
"network_id": ENTERPRISE_EUROPE_NETWORK_ID
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(text("""
|
||||
DELETE FROM organisation WHERE "id" = :network_id
|
||||
"""), input_params)
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2017-06-29 12:44:16.815039
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0103_add_historical_redact'
|
||||
down_revision = 'db6d9d9f06bc'
|
||||
|
||||
@@ -15,8 +17,14 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from flask import current_app
|
||||
|
||||
|
||||
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
|
||||
(
|
||||
@@ -29,12 +37,12 @@ def upgrade():
|
||||
templates.id,
|
||||
false,
|
||||
now(),
|
||||
'{notify_user}'
|
||||
:notify_user_id
|
||||
FROM
|
||||
templates
|
||||
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
|
||||
WHERE template_redacted.template_id IS NULL
|
||||
""".format(notify_user=current_app.config['NOTIFY_USER_ID'])
|
||||
"""), input_params
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0104_more_letter_orgs
|
||||
Revises: 0103_add_historical_redact
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0104_more_letter_orgs'
|
||||
down_revision = '0103_add_historical_redact'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from flask import current_app
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
INSERT INTO dvla_organisation VALUES
|
||||
('003', 'Department for Work and Pensions'),
|
||||
('004', 'Government Equalities Office')
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
# data migration, no downloads
|
||||
pass
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0105_opg_letter_org
|
||||
Revises: 0104_more_letter_orgs
|
||||
Revises: 0103_add_historical_redact
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0105_opg_letter_org'
|
||||
down_revision = '0104_more_letter_orgs'
|
||||
down_revision = '0103_add_historical_redact'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
@@ -8,6 +8,8 @@ Create Date: 2017-07-12 13:35:45.636618
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.dao.date_util import get_month_start_and_end_date_in_utc
|
||||
|
||||
down_revision = '0111_drop_old_service_flags'
|
||||
@@ -26,9 +28,13 @@ def upgrade():
|
||||
for x in res:
|
||||
start_date, end_date = get_month_start_and_end_date_in_utc(
|
||||
datetime(int(x.year), datetime.strptime(x.month, '%B').month, 1))
|
||||
conn.execute("update monthly_billing set start_date = '{}', end_date = '{}' where id = '{}'".format(start_date,
|
||||
end_date,
|
||||
x.id))
|
||||
input_params = {
|
||||
"start_date": start_date,
|
||||
"end_date": end_date,
|
||||
"x_id": x.id
|
||||
}
|
||||
conn.execute(text("update monthly_billing set start_date = :start_date, end_date = :end_date where id = :x_id"),
|
||||
input_params)
|
||||
op.alter_column('monthly_billing', 'start_date', nullable=False)
|
||||
op.alter_column('monthly_billing', 'end_date', nullable=False)
|
||||
op.create_index(op.f('uix_monthly_billing'), 'monthly_billing', ['service_id', 'start_date', 'notification_type'],
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0116_another_letter_org
|
||||
Revises: 0115_add_inbound_numbers
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0116_another_letter_org'
|
||||
down_revision = '0115_add_inbound_numbers'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
INSERT INTO dvla_organisation VALUES
|
||||
('005', 'Companies House')
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
# data migration, no downloads
|
||||
pass
|
||||
@@ -1,14 +1,16 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0117_international_sms_notify
|
||||
Revises: 0116_another_letter_org
|
||||
Revises: 0115_add_inbound_numbers
|
||||
Create Date: 2017-08-29 14:09:41.042061
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0117_international_sms_notify'
|
||||
down_revision = '0116_another_letter_org'
|
||||
down_revision = '0115_add_inbound_numbers'
|
||||
|
||||
from alembic import op
|
||||
from datetime import datetime
|
||||
@@ -18,16 +20,23 @@ NOTIFY_SERVICE_ID = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
INSERT INTO service_permissions VALUES
|
||||
('{}', 'international_sms', '{}')
|
||||
""".format(NOTIFY_SERVICE_ID, datetime.utcnow()))
|
||||
input_params = {
|
||||
"notify_service_id": NOTIFY_SERVICE_ID,
|
||||
"datetime_now": datetime.utcnow()
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
text("INSERT INTO service_permissions VALUES (:notify_service_id, 'international_sms', :datetime_now)"),
|
||||
input_params
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
DELETE FROM service_permissions
|
||||
WHERE
|
||||
service_id = '{}' AND
|
||||
permission = 'international_sms'
|
||||
""".format(NOTIFY_SERVICE_ID))
|
||||
input_params = {
|
||||
"notify_service_id": NOTIFY_SERVICE_ID,
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
text("DELETE FROM service_permissions WHERE service_id = :notify_service_id AND permission = 'international_sms'"),
|
||||
input_params
|
||||
)
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2017-08-29 14:09:41.042061
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0130_service_email_reply_to_row'
|
||||
down_revision = '0129_add_email_auth_permission'
|
||||
|
||||
@@ -18,16 +20,25 @@ EMAIL_REPLY_TO_ID = 'b3a58d57-2337-662a-4cba-40792a9322f2'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"email_reply_to": EMAIL_REPLY_TO_ID,
|
||||
"notify_service_id": NOTIFY_SERVICE_ID
|
||||
}
|
||||
conn.execute(text("""
|
||||
INSERT INTO service_email_reply_to
|
||||
(id, service_id, email_address, is_default, created_at)
|
||||
VALUES
|
||||
('{}','{}', 'testsender@dispostable.com', 'f', NOW())
|
||||
""".format(EMAIL_REPLY_TO_ID, NOTIFY_SERVICE_ID))
|
||||
(:email_reply_to, :notify_service_id, 'testsender@dispostable.com', 'f', NOW())
|
||||
"""), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("""
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"email_reply_to": EMAIL_REPLY_TO_ID,
|
||||
}
|
||||
conn.execute(text("""
|
||||
DELETE FROM service_email_reply_to
|
||||
WHERE id = '{}'
|
||||
""".format(EMAIL_REPLY_TO_ID))
|
||||
WHERE id = :email_reply_to
|
||||
"""), input_params)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import os
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
from app import config
|
||||
"""
|
||||
|
||||
@@ -20,20 +23,24 @@ default_sms_sender = config.FROM_NUMBER
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"default_sms_sender": default_sms_sender
|
||||
}
|
||||
conn.execute(text("""
|
||||
update services set prefix_sms = True
|
||||
where id in (
|
||||
select service_id from service_sms_senders
|
||||
where is_default = True and sms_sender = '{}'
|
||||
where is_default = True and sms_sender = :default_sms_sender
|
||||
)
|
||||
""".format(default_sms_sender))
|
||||
op.execute("""
|
||||
"""), input_params)
|
||||
conn.execute(text("""
|
||||
update services set prefix_sms = False
|
||||
where id in (
|
||||
select service_id from service_sms_senders
|
||||
where is_default = True and sms_sender != '{}'
|
||||
where is_default = True and sms_sender != :default_sms_sender
|
||||
)
|
||||
""".format(default_sms_sender))
|
||||
"""), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -9,7 +9,7 @@ from datetime import datetime
|
||||
|
||||
from alembic import op
|
||||
from flask import current_app
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0134_add_email_2fa_template'
|
||||
down_revision = '0133_set_services_sms_prefix'
|
||||
@@ -20,11 +20,11 @@ template_id = '299726d2-dba6-42b8-8209-30e1d66ea164'
|
||||
def upgrade():
|
||||
template_insert = """
|
||||
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 = """
|
||||
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([
|
||||
@@ -37,48 +37,35 @@ def upgrade():
|
||||
template_name = "Notify email verify code"
|
||||
template_subject = 'Sign in to GOV.UK Notify'
|
||||
|
||||
op.execute(
|
||||
template_history_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
input_params = {
|
||||
'template_id': template_id,
|
||||
'template_name': template_name,
|
||||
'template_type': 'email',
|
||||
'time_now': datetime.utcnow(),
|
||||
'content': template_content,
|
||||
'notify_service_id': current_app.config['NOTIFY_SERVICE_ID'],
|
||||
'subject': template_subject,
|
||||
'user_id': current_app.config['NOTIFY_USER_ID'],
|
||||
'process_type': 'normal'
|
||||
}
|
||||
conn = op.get_bind()
|
||||
|
||||
conn.execute(
|
||||
text(template_history_insert), input_params
|
||||
)
|
||||
|
||||
op.execute(
|
||||
template_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
conn.execute(
|
||||
text(template_insert), input_params
|
||||
)
|
||||
|
||||
# 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():
|
||||
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 template_redacted 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))
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
'template_id': 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)
|
||||
|
||||
@@ -8,6 +8,9 @@ Create Date: 2017-11-10 21:42:59.715203
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.dao.date_util import get_current_calendar_year_start_year
|
||||
|
||||
|
||||
@@ -21,20 +24,28 @@ def upgrade():
|
||||
|
||||
# Step 1: update the column free_sms_fragment_limit in service table if it is empty
|
||||
update_service_table = """
|
||||
UPDATE services SET free_sms_fragment_limit = {} where free_sms_fragment_limit is null
|
||||
""".format(default_limit)
|
||||
|
||||
op.execute(update_service_table)
|
||||
UPDATE services SET free_sms_fragment_limit = :default_limit where free_sms_fragment_limit is null
|
||||
"""
|
||||
input_params = {
|
||||
"default_limit": default_limit
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(text(update_service_table), input_params)
|
||||
|
||||
# Step 2: insert at least one row for every service in current year if none exist for that service
|
||||
input_params = {
|
||||
"current_year": current_year,
|
||||
"default_limit": default_limit,
|
||||
"time_now": datetime.utcnow()
|
||||
}
|
||||
insert_row_if_not_exist = """
|
||||
INSERT INTO annual_billing
|
||||
(id, service_id, financial_year_start, free_sms_fragment_limit, created_at, updated_at)
|
||||
SELECT uuid_in(md5(random()::text)::cstring), id, {}, {}, '{}', '{}'
|
||||
SELECT uuid_in(md5(random()::text)::cstring), id, :current_year, :default_limit, :time_now, :time_now
|
||||
FROM services WHERE id NOT IN
|
||||
(select service_id from annual_billing)
|
||||
""".format(current_year, default_limit, datetime.utcnow(), datetime.utcnow())
|
||||
op.execute(insert_row_if_not_exist)
|
||||
"""
|
||||
conn.execute(text(insert_row_if_not_exist), input_params)
|
||||
|
||||
# Step 3: copy the free_sms_fragment_limit data from the services table across to annual_billing table.
|
||||
update_sms_allowance = """
|
||||
|
||||
@@ -8,6 +8,7 @@ Create Date: 2017-11-07 13:04:04.077142
|
||||
from alembic import op
|
||||
from flask import current_app
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0140_sms_prefix_non_nullable'
|
||||
@@ -15,12 +16,15 @@ down_revision = '0139_migrate_sms_allowance_data'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
op.execute("""
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"id": current_app.config['NOTIFY_SERVICE_ID']
|
||||
}
|
||||
conn.execute(text("""
|
||||
update services
|
||||
set prefix_sms = false
|
||||
where id = '{}'
|
||||
""".format(current_app.config['NOTIFY_SERVICE_ID']))
|
||||
where id = :id
|
||||
"""), input_params)
|
||||
|
||||
op.alter_column(
|
||||
'services',
|
||||
@@ -39,8 +43,12 @@ def downgrade():
|
||||
nullable=True,
|
||||
)
|
||||
|
||||
op.execute("""
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"id": current_app.config['NOTIFY_SERVICE_ID']
|
||||
}
|
||||
conn.execute(text("""
|
||||
update services
|
||||
set prefix_sms = null
|
||||
where id = '{}'
|
||||
""".format(current_app.config['NOTIFY_SERVICE_ID']))
|
||||
where id = :id
|
||||
"""), input_params)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0150_another_letter_org
|
||||
Revises: 0149_add_crown_to_services
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0150_another_letter_org'
|
||||
down_revision = '0149_add_crown_to_services'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('006', 'DWP (Welsh)'),
|
||||
('007', 'Department for Communities'),
|
||||
('008', 'Marine Management Organisation'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,71 +0,0 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0151_refactor_letter_rates
|
||||
Revises: 0150_another_letter_org
|
||||
Create Date: 2017-12-05 10:24:41.232128
|
||||
|
||||
"""
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0151_refactor_letter_rates'
|
||||
down_revision = '0150_another_letter_org'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_table('letter_rate_details')
|
||||
op.drop_table('letter_rates')
|
||||
op.create_table('letter_rates',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('start_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('end_date', sa.DateTime(), nullable=True),
|
||||
sa.Column('sheet_count', sa.Integer(), nullable=False),
|
||||
sa.Column('rate', sa.Numeric(), nullable=False),
|
||||
sa.Column('crown', sa.Boolean(), nullable=False),
|
||||
sa.Column('post_class', sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
start_date = datetime(2016, 3, 31, 23, 00, 00)
|
||||
op.execute("insert into letter_rates values('{}', '{}', null, 1, 0.30, True, 'second')".format(
|
||||
str(uuid.uuid4()), start_date)
|
||||
)
|
||||
op.execute("insert into letter_rates values('{}', '{}', null, 2, 0.33, True, 'second')".format(
|
||||
str(uuid.uuid4()), start_date)
|
||||
)
|
||||
op.execute("insert into letter_rates values('{}', '{}', null, 3, 0.36, True, 'second')".format(
|
||||
str(uuid.uuid4()), start_date)
|
||||
)
|
||||
|
||||
op.execute("insert into letter_rates values('{}', '{}', null, 1, 0.33, False, 'second')".format(
|
||||
str(uuid.uuid4()), start_date)
|
||||
)
|
||||
op.execute("insert into letter_rates values('{}', '{}', null, 2, 0.39, False, 'second')".format(
|
||||
str(uuid.uuid4()), start_date)
|
||||
)
|
||||
op.execute("insert into letter_rates values('{}', '{}', null, 3, 0.45, False, 'second')".format(
|
||||
str(uuid.uuid4()), start_date)
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('letter_rates')
|
||||
op.create_table('letter_rates',
|
||||
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('valid_from', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='letter_rates_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('letter_rate_details',
|
||||
sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('letter_rate_id', postgresql.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('page_total', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('rate', sa.NUMERIC(), autoincrement=False, nullable=False),
|
||||
sa.ForeignKeyConstraint(['letter_rate_id'], ['letter_rates.id'],
|
||||
name='letter_rate_details_letter_rate_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='letter_rate_details_pkey')
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0152_kill_service_free_fragments
|
||||
Revises: 0151_refactor_letter_rates
|
||||
Revises: 0149_add_crown_to_services
|
||||
Create Date: 2017-12-01 16:49:51.178455
|
||||
|
||||
"""
|
||||
@@ -9,7 +9,7 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = '0152_kill_service_free_fragments'
|
||||
down_revision = '0151_refactor_letter_rates'
|
||||
down_revision = '0149_add_crown_to_services'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
"""
|
||||
|
||||
Revision ID: ea1c2f80a50e
|
||||
Revises: 0152_kill_service_free_fragments
|
||||
Create Date: 2018-01-04 10:27:01.014640
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0153_add_is_letter_contact_blank'
|
||||
down_revision = '0152_kill_service_free_fragments'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('templates', sa.Column('is_letter_contact_blank', sa.Boolean(), nullable=True))
|
||||
op.add_column('templates_history', sa.Column('is_letter_contact_blank', sa.Boolean(), nullable=True))
|
||||
op.execute("update templates set is_letter_contact_blank = false")
|
||||
op.execute("update templates_history set is_letter_contact_blank = false")
|
||||
op.alter_column("templates", "is_letter_contact_blank", nullable=False)
|
||||
op.alter_column("templates_history", "is_letter_contact_blank", nullable=False)
|
||||
|
||||
op.create_check_constraint(
|
||||
"ck_templates_contact_block_is_blank",
|
||||
"templates",
|
||||
"Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)"
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_templates_history_contact_block_is_blank",
|
||||
"templates_history",
|
||||
"Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)"
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('templates_history', 'is_letter_contact_blank')
|
||||
op.drop_column('templates', 'is_letter_contact_blank')
|
||||
@@ -1,23 +0,0 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0154_nullable_is_blank
|
||||
Revises: 0153_add_is_letter_contact_blank
|
||||
Create Date: 2018-01-05 15:49:36.522210
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0154_nullable_is_blank'
|
||||
down_revision = '0153_add_is_letter_contact_blank'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('templates', 'is_letter_contact_blank', nullable=True)
|
||||
op.alter_column('templates_history', 'is_letter_contact_blank', nullable=True)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('templates', 'is_letter_contact_blank', nullable=True)
|
||||
op.alter_column('templates_history', 'is_letter_contact_blank', nullable=True)
|
||||
@@ -1,20 +0,0 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0155_revert_0153
|
||||
Revises: 0154_nullable_is_blank
|
||||
Create Date: 2018-01-05 14:09:21.200102
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
revision = '0155_revert_0153'
|
||||
down_revision = '0154_nullable_is_blank'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_column('templates', 'is_letter_contact_blank')
|
||||
op.drop_column('templates_history', 'is_letter_contact_blank')
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0156_set_temp_letter_contact
|
||||
Revises: 0155_revert_0153
|
||||
Revises: 0152_kill_service_free_fragments
|
||||
Create Date: 2018-01-05 17:04:20.596271
|
||||
|
||||
"""
|
||||
@@ -9,7 +9,7 @@ from alembic import op
|
||||
|
||||
|
||||
revision = '0156_set_temp_letter_contact'
|
||||
down_revision = '0155_revert_0153'
|
||||
down_revision = '0152_kill_service_free_fragments'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2017-01-17 15:00:00.000000
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0159_add_historical_redact'
|
||||
down_revision = '0158_remove_rate_limit_default'
|
||||
|
||||
@@ -15,8 +17,13 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from flask import current_app
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute(
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"notify_user": current_app.config['NOTIFY_USER_ID']
|
||||
}
|
||||
conn.execute(text(
|
||||
"""
|
||||
INSERT INTO template_redacted
|
||||
(
|
||||
@@ -29,12 +36,12 @@ def upgrade():
|
||||
templates.id,
|
||||
false,
|
||||
now(),
|
||||
'{notify_user}'
|
||||
:notify_user
|
||||
FROM
|
||||
templates
|
||||
LEFT JOIN template_redacted on template_redacted.template_id = templates.id
|
||||
WHERE template_redacted.template_id IS NULL
|
||||
""".format(notify_user=current_app.config['NOTIFY_USER_ID'])
|
||||
"""), input_params
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0160_another_letter_org
|
||||
Revises: 0159_add_historical_redact
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0160_another_letter_org'
|
||||
down_revision = '0159_add_historical_redact'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('501', 'Environment Agency (PDF letters ONLY)'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0161_email_branding
|
||||
Revises: 0160_another_letter_org
|
||||
Revises: 0159_add_historical_redact
|
||||
Create Date: 2018-01-30 15:35:12.016574
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0161_email_branding'
|
||||
down_revision = '0160_another_letter_org'
|
||||
down_revision = '0159_add_historical_redact'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0165_another_letter_org
|
||||
Revises: 0164_add_organisation_to_service
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0165_another_letter_org'
|
||||
down_revision = '0164_add_organisation_to_service'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('502', 'Welsh Revenue Authority'),
|
||||
('503', 'East Riding of Yorkshire Council'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0166_add_org_user_stuff
|
||||
Revises: 0165_another_letter_org
|
||||
Revises: 0164_add_organisation_to_service
|
||||
Create Date: 2018-02-14 17:25:11.747996
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0166_add_org_user_stuff'
|
||||
down_revision = '0165_another_letter_org'
|
||||
down_revision = '0164_add_organisation_to_service'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -9,7 +9,7 @@ from datetime import datetime
|
||||
|
||||
from alembic import op
|
||||
from flask import current_app
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0171_add_org_invite_template'
|
||||
down_revision = '0170_hidden_non_nullable'
|
||||
@@ -22,12 +22,14 @@ def upgrade():
|
||||
template_insert = """
|
||||
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
|
||||
created_by_id, version, process_type, hidden)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}', false)
|
||||
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False,
|
||||
:notify_service_id, :subject, :user_id, 1, :process_type, false)
|
||||
"""
|
||||
template_history_insert = """
|
||||
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
|
||||
created_by_id, version, process_type, hidden)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', False, '{}', '{}', '{}', 1, '{}', false)
|
||||
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False,
|
||||
:notify_service_id, :subject, :user_id, 1, :process_type, false)
|
||||
"""
|
||||
|
||||
template_content = '\n'.join([
|
||||
@@ -44,52 +46,39 @@ def upgrade():
|
||||
template_name = "Notify organisation invitation email"
|
||||
template_subject = '((user_name)) has invited you to collaborate on ((organisation_name)) on GOV.UK Notify'
|
||||
|
||||
op.execute(
|
||||
template_history_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
input_params = {
|
||||
"template_id": template_id,
|
||||
"template_name": template_name,
|
||||
"template_type": 'email',
|
||||
"time_now": datetime.utcnow(),
|
||||
"content": template_content,
|
||||
"notify_service_id": current_app.config['NOTIFY_SERVICE_ID'],
|
||||
"subject": template_subject,
|
||||
"user_id": current_app.config['NOTIFY_USER_ID'],
|
||||
"process_type": 'normal'
|
||||
}
|
||||
conn = op.get_bind()
|
||||
conn.execute(
|
||||
text(template_history_insert), input_params
|
||||
)
|
||||
|
||||
op.execute(
|
||||
template_insert.format(
|
||||
template_id,
|
||||
template_name,
|
||||
'email',
|
||||
datetime.utcnow(),
|
||||
template_content,
|
||||
current_app.config['NOTIFY_SERVICE_ID'],
|
||||
template_subject,
|
||||
current_app.config['NOTIFY_USER_ID'],
|
||||
'normal'
|
||||
)
|
||||
conn.execute(
|
||||
text(template_insert), input_params
|
||||
)
|
||||
|
||||
# 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
|
||||
op.drop_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', type_='unique')
|
||||
|
||||
|
||||
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 template_redacted 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))
|
||||
input_params = {
|
||||
'template_id': template_id
|
||||
}
|
||||
conn = op.get_bind()
|
||||
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)
|
||||
op.create_unique_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', ['service_id', 'organisation_id'])
|
||||
|
||||
@@ -18,13 +18,13 @@ def upgrade():
|
||||
op.get_bind()
|
||||
op.execute("""
|
||||
update templates
|
||||
set process_type = '{}'
|
||||
set process_type = 'normal'
|
||||
where templates.id in (
|
||||
select templates.id from templates
|
||||
join templates_history on templates.id=templates_history.id
|
||||
where templates_history.name = 'Example text message template'
|
||||
)
|
||||
""".format(NORMAL))
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0180_another_letter_org
|
||||
Revises: 0179_billing_primary_const
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0180_another_letter_org'
|
||||
down_revision = '0179_billing_primary_const'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('504', 'Rother District Council'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0181_billing_primary_key
|
||||
Revises: 0180_another_letter_org
|
||||
Revises: 0179_billing_primary_const
|
||||
Create Date: 2018-03-21 13:41:26.203712
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0181_billing_primary_key'
|
||||
down_revision = '0180_another_letter_org'
|
||||
down_revision = '0179_billing_primary_const'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0187_another_letter_org
|
||||
Revises: 0186_rename_is_active_columns
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0187_another_letter_org'
|
||||
down_revision = '0186_rename_is_active_columns'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('505', 'CADW'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0188_add_ft_notification_status
|
||||
Revises: 0187_another_letter_org
|
||||
Revises: 0186_rename_is_active_columns
|
||||
Create Date: 2018-05-03 10:10:41.824981
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0188_add_ft_notification_status'
|
||||
down_revision = '0187_another_letter_org'
|
||||
down_revision = '0186_rename_is_active_columns'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0190_another_letter_org
|
||||
Revises: 0189_ft_billing_data_type
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0190_another_letter_org'
|
||||
down_revision = '0189_ft_billing_data_type'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('506', 'Tyne and Wear Fire and Rescue Service'),
|
||||
('507', 'Thames Valley Police'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,14 +1,14 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0191_ft_billing_pkey
|
||||
Revises: 0190_another_letter_org
|
||||
Revises: 0189_ft_billing_data
|
||||
Create Date: 2018-05-21 14:24:27.229511
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
revision = '0191_ft_billing_pkey'
|
||||
down_revision = '0190_another_letter_org'
|
||||
down_revision = '0189_ft_billing_data_type'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -7,6 +7,8 @@ Create Date: 2018-02-21 12:05:00
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import text
|
||||
|
||||
revision = '0198_add_caseworking_permission'
|
||||
down_revision = '0197_service_contact_link'
|
||||
|
||||
@@ -16,11 +18,17 @@ PERMISSION_NAME = "caseworking"
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.get_bind()
|
||||
op.execute("insert into service_permission_types values('{}')".format(PERMISSION_NAME))
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"permission_name": PERMISSION_NAME
|
||||
}
|
||||
conn.execute(text("insert into service_permission_types values(:permission_name)"), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.get_bind()
|
||||
op.execute("delete from service_permissions where permission = '{}'".format(PERMISSION_NAME))
|
||||
op.execute("delete from service_permission_types where name = '{}'".format(PERMISSION_NAME))
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"permission_name": PERMISSION_NAME
|
||||
}
|
||||
conn.execute(text("delete from service_permissions where permission = :permission_name"), input_params)
|
||||
conn.execute(text("delete from service_permission_types where name = :permission_name"), input_params)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0199_another_letter_org
|
||||
Revises: 0198_add_caseworking_permission
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0199_another_letter_org'
|
||||
down_revision = '0198_add_caseworking_permission'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('009', 'HM Passport Office'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0200_another_letter_org
|
||||
Revises: 0199_another_letter_org
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0200_another_letter_org'
|
||||
down_revision = '0199_another_letter_org'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('508', 'Ofgem'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0201_another_letter_org
|
||||
Revises: 0200_another_letter_org
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0201_another_letter_org'
|
||||
down_revision = '0200_another_letter_org'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('509', 'Hackney Council'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,37 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0202_new_letter_pricing
|
||||
Revises: 0201_another_letter_org
|
||||
Create Date: 2017-07-09 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
revision = '0202_new_letter_pricing'
|
||||
down_revision = '0201_another_letter_org'
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
|
||||
|
||||
start = datetime(2018, 6, 30, 23, 0)
|
||||
|
||||
NEW_RATES = [
|
||||
(uuid.uuid4(), start, 4, 0.39, True, 'second'),
|
||||
(uuid.uuid4(), start, 4, 0.51, False, 'second'),
|
||||
(uuid.uuid4(), start, 5, 0.42, True, 'second'),
|
||||
(uuid.uuid4(), start, 5, 0.57, False, 'second'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
for id, start_date, sheet_count, rate, crown, post_class in NEW_RATES:
|
||||
conn.execute("""
|
||||
INSERT INTO letter_rates (id, start_date, sheet_count, rate, crown, post_class)
|
||||
VALUES ('{}', '{}', '{}', '{}', '{}', '{}')
|
||||
""".format(id, start_date, sheet_count, rate, crown, post_class))
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -1,14 +1,14 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0203_fix_old_incomplete_jobs
|
||||
Revises: 0202_new_letter_pricing
|
||||
Revises: 0198_add_caseworking_permission
|
||||
Create Date: 2017-06-29 12:44:16.815039
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0203_fix_old_incomplete_jobs'
|
||||
down_revision = '0202_new_letter_pricing'
|
||||
down_revision = '0198_add_caseworking_permission'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
@@ -11,13 +11,11 @@ from alembic import op
|
||||
revision = '0212_remove_caseworking'
|
||||
down_revision = '0211_email_branding_update'
|
||||
|
||||
PERMISSION_NAME = "caseworking"
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("delete from service_permissions where permission = '{}'".format(PERMISSION_NAME))
|
||||
op.execute("delete from service_permission_types where name = '{}'".format(PERMISSION_NAME))
|
||||
op.execute("delete from service_permissions where permission = 'caseworking'")
|
||||
op.execute("delete from service_permission_types where name = 'caseworking'")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute("insert into service_permission_types values('{}')".format(PERMISSION_NAME))
|
||||
op.execute("insert into service_permission_types values('caseworking')")
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0214_another_letter_org
|
||||
Revises: 0213_brand_colour_domain_
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0214_another_letter_org'
|
||||
down_revision = '0213_brand_colour_domain'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('510', 'Pension Wise'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0215_email_brand_type
|
||||
Revises: 0214_another_letter_org
|
||||
Revises: 0213_brand_colour_domain_
|
||||
Create Date: 2018-08-23 11:48:00.800968
|
||||
|
||||
"""
|
||||
@@ -9,7 +9,7 @@ from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = '0215_email_brand_type'
|
||||
down_revision = '0214_another_letter_org'
|
||||
down_revision = '0213_brand_colour_domain'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
"""
|
||||
Revision ID: 0217_default_email_branding
|
||||
Revises: 0216_remove_colours
|
||||
Create Date: 2018-08-24 13:36:49.346156
|
||||
"""
|
||||
from alembic import op
|
||||
from app.models import BRANDING_ORG
|
||||
|
||||
revision = '0217_default_email_branding'
|
||||
down_revision = '0216_remove_colours'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
update
|
||||
email_branding
|
||||
set
|
||||
brand_type = '{}'
|
||||
where
|
||||
brand_type = null
|
||||
""".format(BRANDING_ORG))
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0218_another_letter_org
|
||||
Revises: 0217_default_email_branding
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0218_another_letter_org'
|
||||
down_revision = '0217_default_email_branding'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('511', 'NHS'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,24 +1,30 @@
|
||||
"""
|
||||
Revision ID: 0219_default_email_branding
|
||||
Revises: 0218_another_letter_org
|
||||
Revises: 0216_remove_colours
|
||||
Create Date: 2018-08-24 13:36:49.346156
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.models import BRANDING_ORG
|
||||
|
||||
revision = '0219_default_email_branding'
|
||||
down_revision = '0218_another_letter_org'
|
||||
down_revision = '0216_remove_colours'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
conn = op.get_bind()
|
||||
input_params = {
|
||||
"branding_org": BRANDING_ORG
|
||||
}
|
||||
conn.execute(text("""
|
||||
update
|
||||
email_branding
|
||||
set
|
||||
brand_type = '{}'
|
||||
brand_type = :branding_org
|
||||
where
|
||||
brand_type is null
|
||||
""".format(BRANDING_ORG))
|
||||
"""), input_params)
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -4,7 +4,6 @@ Revises: 0220_email_brand_type_non_null
|
||||
Create Date: 2018-08-24 13:36:49.346156
|
||||
"""
|
||||
from alembic import op
|
||||
from app.models import BRANDING_ORG, BRANDING_GOVUK
|
||||
|
||||
|
||||
revision = '0221_nullable_service_branding'
|
||||
@@ -25,17 +24,17 @@ def upgrade():
|
||||
update
|
||||
email_branding
|
||||
set
|
||||
brand_type = '{}'
|
||||
brand_type = 'org'
|
||||
where
|
||||
brand_type = '{}'
|
||||
""".format(BRANDING_ORG, BRANDING_GOVUK))
|
||||
brand_type = 'govuk'
|
||||
""")
|
||||
|
||||
op.execute("""
|
||||
delete from
|
||||
branding_type
|
||||
where
|
||||
name = '{}'
|
||||
""".format(BRANDING_GOVUK))
|
||||
name = 'govuk'
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
@@ -53,5 +52,5 @@ def downgrade():
|
||||
branding_type
|
||||
(name)
|
||||
values
|
||||
('{}')
|
||||
""".format(BRANDING_GOVUK))
|
||||
('govuk')
|
||||
""")
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0225_another_letter_org
|
||||
Revises: 0224_returned_letter_status
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0225_another_letter_org'
|
||||
down_revision = '0224_returned_letter_status'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('512', 'Vale of Glamorgan'),
|
||||
('513', 'Rother and Wealden'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0226_service_postage
|
||||
Revises: 0225_another_letter_org
|
||||
Revises: 0224_returned_letter_status
|
||||
Create Date: 2018-09-13 16:23:59.168877
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0226_service_postage'
|
||||
down_revision = '0225_another_letter_org'
|
||||
down_revision = '0224_returned_letter_status'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0229_new_letter_rates
|
||||
Revises: 0228_notification_postage
|
||||
|
||||
"""
|
||||
|
||||
revision = '0229_new_letter_rates'
|
||||
down_revision = '0228_notification_postage'
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
|
||||
|
||||
START = datetime(2018, 9, 30, 23, 0)
|
||||
|
||||
NEW_RATES = [
|
||||
(uuid.uuid4(), START, 1, 0.30, False, 'second'),
|
||||
(uuid.uuid4(), START, 2, 0.35, True, 'second'),
|
||||
(uuid.uuid4(), START, 2, 0.35, False, 'second'),
|
||||
(uuid.uuid4(), START, 3, 0.40, True, 'second'),
|
||||
(uuid.uuid4(), START, 3, 0.40, False, 'second'),
|
||||
(uuid.uuid4(), START, 4, 0.45, True, 'second'),
|
||||
(uuid.uuid4(), START, 4, 0.45, False, 'second'),
|
||||
(uuid.uuid4(), START, 5, 0.50, True, 'second'),
|
||||
(uuid.uuid4(), START, 5, 0.50, False, 'second'),
|
||||
(uuid.uuid4(), START, 1, 0.56, True, 'first'),
|
||||
(uuid.uuid4(), START, 1, 0.56, False, 'first'),
|
||||
(uuid.uuid4(), START, 2, 0.61, True, 'first'),
|
||||
(uuid.uuid4(), START, 2, 0.61, False, 'first'),
|
||||
(uuid.uuid4(), START, 3, 0.66, True, 'first'),
|
||||
(uuid.uuid4(), START, 3, 0.66, False, 'first'),
|
||||
(uuid.uuid4(), START, 4, 0.71, True, 'first'),
|
||||
(uuid.uuid4(), START, 4, 0.71, False, 'first'),
|
||||
(uuid.uuid4(), START, 5, 0.76, True, 'first'),
|
||||
(uuid.uuid4(), START, 5, 0.76, False, 'first'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute(text("""
|
||||
update
|
||||
letter_rates
|
||||
set
|
||||
end_date = :start
|
||||
where
|
||||
rate != 0.30
|
||||
"""), start=START)
|
||||
|
||||
for id, start_date, sheet_count, rate, crown, post_class in NEW_RATES:
|
||||
conn.execute(text("""
|
||||
INSERT INTO letter_rates (id, start_date, sheet_count, rate, crown, post_class)
|
||||
VALUES (:id, :start_date, :sheet_count, :rate, :crown, :post_class)
|
||||
"""), id=id, start_date=start_date, sheet_count=sheet_count, rate=rate, crown=crown, post_class=post_class)
|
||||
|
||||
|
||||
def downgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute(text("""
|
||||
delete from
|
||||
letter_rates
|
||||
where
|
||||
start_date = :start
|
||||
"""), start=START)
|
||||
|
||||
conn.execute(text("""
|
||||
update
|
||||
letter_rates
|
||||
set
|
||||
end_date = null
|
||||
where
|
||||
end_date = :start
|
||||
"""), start=START)
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0230_noti_postage_constraint_1
|
||||
Revises: 0229_new_letter_rates
|
||||
Revises: 0228_notification_postage
|
||||
Create Date: 2018-09-19 11:42:52.229430
|
||||
|
||||
"""
|
||||
@@ -9,7 +9,7 @@ from alembic import op
|
||||
|
||||
|
||||
revision = '0230_noti_postage_constraint_1'
|
||||
down_revision = '0229_new_letter_rates'
|
||||
down_revision = '0228_notification_postage'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0230_noti_postage_constraint_3
|
||||
Revision ID: 0232_noti_postage_constraint_3
|
||||
Revises: 0230_noti_postage_constraint_2
|
||||
Create Date: 2018-09-19 11:42:52.229430
|
||||
|
||||
@@ -8,7 +8,7 @@ Create Date: 2018-09-19 11:42:52.229430
|
||||
from alembic import op
|
||||
|
||||
|
||||
revision = '0230_noti_postage_constraint_3'
|
||||
revision = '0232_noti_postage_constraint_3'
|
||||
down_revision = '0230_noti_postage_constraint_2'
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0233_updated_first_class_dates
|
||||
Revises: 0230_noti_postage_constraint_3
|
||||
|
||||
"""
|
||||
|
||||
revision = '0233_updated_first_class_dates'
|
||||
down_revision = '0230_noti_postage_constraint_3'
|
||||
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
from sqlalchemy.sql import text
|
||||
|
||||
|
||||
START_DATE = datetime(2018, 8, 31, 23, 0)
|
||||
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute(text(
|
||||
"""UPDATE letter_rates SET start_date = :start_date WHERE post_class = 'first'"""
|
||||
), start_date=START_DATE)
|
||||
|
||||
|
||||
def downgrade():
|
||||
'''
|
||||
This data migration should not be downgraded. Downgrading may cause billing errors
|
||||
and the /montly-usage endpoint to stop working.
|
||||
'''
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0234_ft_billing_postage
|
||||
Revises: 0233_updated_first_class_dates
|
||||
Revises: 0232_noti_postage_constraint_3
|
||||
Create Date: 2018-09-28 14:43:26.100884
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0234_ft_billing_postage'
|
||||
down_revision = '0233_updated_first_class_dates'
|
||||
down_revision = '0232_noti_postage_constraint_3'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0236_another_letter_org
|
||||
Revises: 0235_add_postage_to_pk
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0236_another_letter_org'
|
||||
down_revision = '0235_add_postage_to_pk'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('514', 'Brighton and Hove city council'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}')
|
||||
""".format(numeric_id, name))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0237_add_filename_to_dvla_org
|
||||
Revises: 0236_another_letter_org
|
||||
Revises: 0235_add_postage_to_pk
|
||||
Create Date: 2018-09-28 15:39:21.115358
|
||||
|
||||
"""
|
||||
@@ -11,7 +11,7 @@ from sqlalchemy.sql import text
|
||||
|
||||
|
||||
revision = '0237_add_filename_to_dvla_org'
|
||||
down_revision = '0236_another_letter_org'
|
||||
down_revision = '0235_add_postage_to_pk'
|
||||
|
||||
|
||||
LOGOS = {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0241_another_letter_org
|
||||
Revises: 0240_dvla_org_non_nullable
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0241_another_letter_org'
|
||||
down_revision = '0240_dvla_org_non_nullable'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('515', 'ACAS', 'acas'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}', '{}')
|
||||
""".format(numeric_id, name, filename))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0242_template_folders
|
||||
Revises: 0241_another_letter_org
|
||||
Revises: 0240_dvla_org_non_nullable
|
||||
Create Date: 2018-10-26 16:00:40.173840
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0242_template_folders'
|
||||
down_revision = '0241_another_letter_org'
|
||||
down_revision = '0240_dvla_org_non_nullable'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0243_another_letter_org
|
||||
Revises: 0242_template_folders
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0243_another_letter_org'
|
||||
down_revision = '0242_template_folders'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('516', 'Worcestershire County Council', 'worcestershire'),
|
||||
('517', 'Buckinghamshire County Council', 'buckinghamshire'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}', '{}')
|
||||
""".format(numeric_id, name, filename))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0244_another_letter_org
|
||||
Revises: 0243_another_letter_org
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0244_another_letter_org'
|
||||
down_revision = '0243_another_letter_org'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('518', 'Bournemouth Borough Council', 'bournemouth'),
|
||||
('519', 'Hampshire County Council', 'hants'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}', '{}')
|
||||
""".format(numeric_id, name, filename))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0245_archived_flag_jobs
|
||||
Revises: 0244_another_letter_org
|
||||
Revises: 0242_template_folders
|
||||
Create Date: 2018-11-22 16:32:01.105803
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0245_archived_flag_jobs'
|
||||
down_revision = '0244_another_letter_org'
|
||||
down_revision = '0242_template_folders'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0247_another_letter_org
|
||||
Revises: 0246_notifications_index
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0247_another_letter_org'
|
||||
down_revision = '0246_notifications_index'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('520', 'Neath Port Talbot Council', 'npt'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}', '{}')
|
||||
""".format(numeric_id, name, filename))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0248_enable_choose_postage
|
||||
Revises: 0247_another_letter_org
|
||||
Revises: 0246_notifications_index
|
||||
Create Date: 2018-12-14 12:09:31.375634
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0248_enable_choose_postage'
|
||||
down_revision = '0247_another_letter_org'
|
||||
down_revision = '0246_notifications_index'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0249_another_letter_org
|
||||
Revises: 0248_enable_choose_postage
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0249_another_letter_org'
|
||||
down_revision = '0248_enable_choose_postage'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('521', 'North Somerset Council', 'north-somerset'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}', '{}')
|
||||
""".format(numeric_id, name, filename))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0250_drop_stats_template_table
|
||||
Revises: 0249_another_letter_org
|
||||
Revises: 0248_enable_choose_postage
|
||||
Create Date: 2019-01-15 16:47:08.049369
|
||||
|
||||
"""
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0250_drop_stats_template_table'
|
||||
down_revision = '0249_another_letter_org'
|
||||
down_revision = '0248_enable_choose_postage'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0251_another_letter_org
|
||||
Revises: 0250_drop_stats_template_table
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0251_another_letter_org'
|
||||
down_revision = '0250_drop_stats_template_table'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
NEW_ORGANISATIONS = [
|
||||
('522', 'Anglesey Council', 'anglesey'),
|
||||
('523', 'Angus Council', 'angus'),
|
||||
('524', 'Cheshire East Council', 'cheshire-east'),
|
||||
('525', 'Newham Council', 'newham'),
|
||||
('526', 'Warwickshire Council', 'warwickshire'),
|
||||
]
|
||||
|
||||
|
||||
def upgrade():
|
||||
for numeric_id, name, filename in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
INSERT
|
||||
INTO dvla_organisation
|
||||
VALUES ('{}', '{}', '{}')
|
||||
""".format(numeric_id, name, filename))
|
||||
|
||||
|
||||
def downgrade():
|
||||
for numeric_id, _, _ in NEW_ORGANISATIONS:
|
||||
op.execute("""
|
||||
DELETE
|
||||
FROM dvla_organisation
|
||||
WHERE id = '{}'
|
||||
""".format(numeric_id))
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0252_letter_branding_table
|
||||
Revises: 0251_another_letter_org
|
||||
Revises: 0250_drop_stats_template_table
|
||||
Create Date: 2019-01-17 15:45:33.242955
|
||||
|
||||
"""
|
||||
@@ -11,7 +11,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0252_letter_branding_table'
|
||||
down_revision = '0251_another_letter_org'
|
||||
down_revision = '0250_drop_stats_template_table'
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
@@ -17,7 +17,7 @@ def upgrade():
|
||||
INSERT INTO
|
||||
service_permissions (service_id, permission, created_at)
|
||||
SELECT
|
||||
id, '{permission}', now()
|
||||
id, 'edit_folders', now()
|
||||
FROM
|
||||
services
|
||||
WHERE
|
||||
@@ -27,11 +27,9 @@ def upgrade():
|
||||
service_permissions
|
||||
WHERE
|
||||
service_id = services.id and
|
||||
permission = '{permission}'
|
||||
permission = 'edit_folders'
|
||||
)
|
||||
""".format(
|
||||
permission='edit_folders'
|
||||
))
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user