more files

This commit is contained in:
Kenneth Kehl
2023-07-17 09:03:06 -07:00
parent de4812efee
commit d872bfc5ee
8 changed files with 118 additions and 60 deletions

View File

@@ -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'
@@ -34,17 +36,30 @@ def upgrade():
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, 'MMG', 'mmg', 10, 'sms', 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()))
input_params = {
"id": uuid.uuid4()
}
conn.execute(
text("INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active) values (:id, 'Firetext', 'firetext', 20, 'sms', true)"), input_params
)
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()))
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 ('{}', 'AWS SNS', 'sns', 10, 'sms', true)".format(str(uuid.uuid4()))
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_rates set provider_id = (select id from provider_details where identifier = 'mmg') where provider = 'mmg'"
@@ -71,6 +86,7 @@ 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')

View File

@@ -7,6 +7,8 @@ Create Date: 2016-05-05 09:14:29.328841
"""
# revision identifiers, used by Alembic.
from sqlalchemy import text
revision = '0013_add_loadtest_client'
down_revision = '0012_complete_provider_details'
@@ -16,10 +18,14 @@ 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 upgrade():
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, 'Loadtesting', 'loadtesting', 30, 'sms', true)"), input_params
)

View File

@@ -8,6 +8,8 @@ Create Date: 2017-03-02 10:32:28.984947
import uuid
from datetime import datetime
from sqlalchemy import text
revision = '0066_add_dvla_provider'
down_revision = '0065_users_current_session_id'
@@ -15,14 +17,26 @@ from alembic import op
def upgrade():
conn = op.get_bind()
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)
input_params = {
"provider_id": provider_id
}
conn.execute(
text("INSERT INTO provider_details (id, display_name, identifier, priority, notification_type, active, version) values (:provider_id, 'DVLA', 'dvla', 50, 'letter', true, 1)"), input_params
)
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)
conn.execute(
text("INSERT INTO provider_details_history (id, display_name, identifier, priority, notification_type, active, version) values (:provider_id, 'DVLA', 'dvla', 50, 'letter', true, 1)"), input_params
)
input_params = {
"id": uuid.uuid4(),
"time_now": datetime.utcnow(),
"provider_id": provider_id
}
conn.execute(
text("INSERT INTO provider_rates (id, valid_from, rate, provider_id) VALUES (:id, :time_now, 1.0, :provider_id)"),
input_params
)
op.execute("INSERT INTO provider_rates (id, valid_from, rate, provider_id) VALUES ('{}', '{}', 1.0, '{}')".format(uuid.uuid4(), datetime.utcnow(), provider_id))
def downgrade():

View File

@@ -8,6 +8,8 @@ Create Date: 2017-04-24 12:10:02.116278
import uuid
from sqlalchemy import text
revision = '0074_update_sms_rate'
down_revision = '0073_add_international_sms_flag'
@@ -15,11 +17,13 @@ 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())
)
conn = op.get_bind()
input_params = {
"id": uuid.uuid4()
}
conn.execute(text("INSERT INTO provider_rates (id, valid_from, rate, provider_id) "
"VALUES (:id, '2017-04-01 00:00:00', 1.58, "
"(SELECT id FROM provider_details WHERE identifier = 'mmg'))"), input_params)
def downgrade():

View File

@@ -7,6 +7,8 @@ Create Date: 2017-06-05 16:15:17.744908
"""
# revision identifiers, used by Alembic.
from sqlalchemy import text
revision = '0093_data_gov_uk'
down_revision = '0092_add_inbound_provider'
@@ -16,17 +18,17 @@ from sqlalchemy.dialects import postgresql
DATA_GOV_UK_ID = '123496d4-44cb-4324-8e0a-4187101f4bdc'
input_params = {
"data_gov_uk_id": DATA_GOV_UK_ID
}
def upgrade():
op.execute("""INSERT INTO organisation VALUES (
'{}',
'',
'data_gov_uk_x2.png',
'data gov.uk'
)""".format(DATA_GOV_UK_ID))
conn = op.get_bind()
conn.execute(text("INSERT INTO organisation VALUES (:data_gov_uk_id,'', 'data_gov_uk_x2.png', 'data gov.uk')"),
input_params)
def downgrade():
op.execute("""
DELETE FROM organisation WHERE "id" = '{}'
""".format(DATA_GOV_UK_ID))
conn = op.get_bind()
conn.execute(text("DELETE FROM organisation WHERE id = :data_gov_uk_id"), input_params)

View File

@@ -7,6 +7,8 @@ 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'
@@ -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
)

View File

@@ -7,6 +7,8 @@ Create Date: 2017-06-29 12:44:16.815039
"""
# revision identifiers, used by Alembic.
from sqlalchemy import text
revision = '0150_another_letter_org'
down_revision = '0149_add_crown_to_services'
@@ -21,18 +23,19 @@ NEW_ORGANISATIONS = [
def upgrade():
conn = op.get_bind()
for numeric_id, name in NEW_ORGANISATIONS:
op.execute("""
INSERT
INTO dvla_organisation
VALUES ('{}', '{}')
""".format(numeric_id, name))
input_params = {
"numeric_id": numeric_id,
"name": name
}
conn.execute(text("INSERT INTO dvla_organisation VALUES (:numeric_id, :name)"), input_params)
def downgrade():
conn = op.get_bind()
for numeric_id, _ in NEW_ORGANISATIONS:
op.execute("""
DELETE
FROM dvla_organisation
WHERE id = '{}'
""".format(numeric_id))
input_params = {
"numeric_id": numeric_id
}
conn.execute(text("DELETE FROM dvla_organisation WHERE id = :numeric_id"), input_params)

View File

@@ -7,6 +7,8 @@ Create Date: 2017-06-29 12:44:16.815039
"""
# revision identifiers, used by Alembic.
from sqlalchemy import text
revision = '0160_another_letter_org'
down_revision = '0159_add_historical_redact'
@@ -19,18 +21,20 @@ NEW_ORGANISATIONS = [
def upgrade():
conn = op.get_bind()
for numeric_id, name in NEW_ORGANISATIONS:
op.execute("""
INSERT
INTO dvla_organisation
VALUES ('{}', '{}')
""".format(numeric_id, name))
input_params = {
"numeric_id": numeric_id,
"name": name
}
conn.execute(text("INSERT INTO dvla_organisation VALUES (:numeric_id, :name)"), input_params)
def downgrade():
conn = op.get_bind()
for numeric_id, _ in NEW_ORGANISATIONS:
op.execute("""
DELETE
FROM dvla_organisation
WHERE id = '{}'
""".format(numeric_id))
input_params = {
"numeric_id": numeric_id
}
conn.execute(text("DELETE FROM dvla_organisation WHERE id = :numeric_id"), input_params)