mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-09 14:42:24 -05:00
more
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')
|
||||
|
||||
@@ -27,43 +27,16 @@ 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()))
|
||||
)
|
||||
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'"
|
||||
)
|
||||
op.execute(
|
||||
"UPDATE provider_statistics set provider_id = (select id from provider_details where identifier = 'ses') where provider = 'ses'"
|
||||
)
|
||||
@@ -71,12 +44,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)
|
||||
@@ -15,16 +15,18 @@ down_revision = '0364_drop_old_column'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_table('provider_rates')
|
||||
pass
|
||||
# op.drop_table('provider_rates')
|
||||
|
||||
|
||||
def downgrade():
|
||||
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_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('rate', sa.Numeric(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.ForeignKeyConstraint(['provider_id'], ['provider_details.id'], ),
|
||||
)
|
||||
pass
|
||||
# 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_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
# sa.Column('rate', sa.Numeric(), nullable=False),
|
||||
# sa.PrimaryKeyConstraint('id'),
|
||||
# sa.ForeignKeyConstraint(['provider_id'], ['provider_details.id'], ),
|
||||
# )
|
||||
|
||||
@@ -14,8 +14,9 @@ down_revision = '0381_encrypted_column_types'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("DELETE FROM provider_details WHERE identifier IN ('mmg', 'firetext')")
|
||||
op.execute("DELETE FROM provider_details_history WHERE identifier IN ('mmg', 'firetext')")
|
||||
pass
|
||||
# op.execute("DELETE FROM provider_details WHERE identifier IN ('mmg', 'firetext')")
|
||||
# op.execute("DELETE FROM provider_details_history WHERE identifier IN ('mmg', 'firetext')")
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
Reference in New Issue
Block a user