wait don't do that

This commit is contained in:
stvnrlly
2022-11-21 12:19:58 -05:00
parent 7f5c3c785e
commit 9faff5940e
11 changed files with 36 additions and 36 deletions

View File

@@ -16,7 +16,7 @@ down_revision = '0173_create_daily_sorted_letter'
def upgrade(): def upgrade():
# Create notifications_for_today table # Create notifications_for_today table
op.create_table('ft_billing', op.create_table('ft_billing',
sa.Column('local_date', sa.Date(), nullable=True), sa.Column('bst_date', sa.Date(), nullable=True),
sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
sa.Column('organisation_id', postgresql.UUID(as_uuid=True), nullable=True), sa.Column('organisation_id', postgresql.UUID(as_uuid=True), nullable=True),
@@ -29,15 +29,15 @@ def upgrade():
sa.Column('rate', sa.Numeric(), nullable=True), sa.Column('rate', sa.Numeric(), nullable=True),
sa.Column('billable_units', sa.Numeric(), nullable=True), sa.Column('billable_units', sa.Numeric(), nullable=True),
sa.Column('notifications_sent', sa.Integer(), nullable=True), sa.Column('notifications_sent', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('local_date', 'template_id') sa.PrimaryKeyConstraint('bst_date', 'template_id')
) )
# Set indexes # Set indexes
op.create_index(op.f('ix_ft_billing_local_date'), 'ft_billing', ['local_date'], unique=False) op.create_index(op.f('ix_ft_billing_bst_date'), 'ft_billing', ['bst_date'], unique=False)
op.create_index(op.f('ix_ft_billing_service_id'), 'ft_billing', ['service_id'], unique=False) op.create_index(op.f('ix_ft_billing_service_id'), 'ft_billing', ['service_id'], unique=False)
# Create dm_datetime table # Create dm_datetime table
op.create_table('dm_datetime', op.create_table('dm_datetime',
sa.Column('local_date', sa.Date(), nullable=False), sa.Column('bst_date', sa.Date(), nullable=False),
sa.Column('year', sa.Integer(), nullable=False), sa.Column('year', sa.Integer(), nullable=False),
sa.Column('month', sa.Integer(), nullable=False), sa.Column('month', sa.Integer(), nullable=False),
sa.Column('month_name', sa.String(), nullable=False), sa.Column('month_name', sa.String(), nullable=False),
@@ -53,18 +53,18 @@ def upgrade():
sa.Column('financial_year', sa.Integer(), nullable=True), sa.Column('financial_year', sa.Integer(), nullable=True),
sa.Column('utc_daytime_start', sa.DateTime(), nullable=False), sa.Column('utc_daytime_start', sa.DateTime(), nullable=False),
sa.Column('utc_daytime_end', sa.DateTime(), nullable=False), sa.Column('utc_daytime_end', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('local_date') sa.PrimaryKeyConstraint('bst_date')
) )
# Set indexes # Set indexes
op.create_index(op.f('ix_dm_datetime_yearmonth'), 'dm_datetime', ['year', 'month'], unique=False) op.create_index(op.f('ix_dm_datetime_yearmonth'), 'dm_datetime', ['year', 'month'], unique=False)
op.create_index(op.f('ix_dm_datetime_local_date'), 'dm_datetime', ['local_date'], unique=False) op.create_index(op.f('ix_dm_datetime_bst_date'), 'dm_datetime', ['bst_date'], unique=False)
# Insert data into table # Insert data into table
op.execute( op.execute(
""" """
INSERT into dm_datetime ( INSERT into dm_datetime (
SELECT SELECT
datum AS local_date, datum AS bst_date,
EXTRACT(YEAR FROM datum) AS year, EXTRACT(YEAR FROM datum) AS year,
EXTRACT(MONTH FROM datum) AS month, EXTRACT(MONTH FROM datum) AS month,
-- Localized month name -- Localized month name
@@ -91,7 +91,7 @@ def upgrade():
FROM generate_series(0,365*50+10) AS SEQUENCE(DAY) FROM generate_series(0,365*50+10) AS SEQUENCE(DAY)
GROUP BY SEQUENCE.day GROUP BY SEQUENCE.day
) DQ ) DQ
ORDER BY local_date ORDER BY bst_date
); );
""" """
) )

View File

@@ -20,7 +20,7 @@ def upgrade():
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
# These are the orthogonal dimensions that define a row (except international). # These are the orthogonal dimensions that define a row (except international).
# These entries define a unique record. # These entries define a unique record.
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'rate_multiplier', 'rate_multiplier',
'provider', 'provider',
@@ -32,5 +32,5 @@ def downgrade():
op.add_column('ft_billing', sa.Column('annual_billing_id', postgresql.UUID(), autoincrement=False, nullable=True)) op.add_column('ft_billing', sa.Column('annual_billing_id', postgresql.UUID(), autoincrement=False, nullable=True))
op.add_column('ft_billing', sa.Column('crown', sa.TEXT(), autoincrement=False, nullable=True)) op.add_column('ft_billing', sa.Column('crown', sa.TEXT(), autoincrement=False, nullable=True))
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id']) 'template_id'])

View File

@@ -19,7 +19,7 @@ def upgrade():
nullable=False) nullable=False)
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'rate_multiplier', 'rate_multiplier',
'provider', 'provider',
@@ -34,7 +34,7 @@ def downgrade():
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'rate_multiplier', 'rate_multiplier',
'provider', 'provider',

View File

@@ -24,7 +24,7 @@ def upgrade():
""" """
INSERT into dm_datetime ( INSERT into dm_datetime (
SELECT SELECT
datum AS local_date, datum AS bst_date,
EXTRACT(YEAR FROM datum) AS year, EXTRACT(YEAR FROM datum) AS year,
EXTRACT(MONTH FROM datum) AS month, EXTRACT(MONTH FROM datum) AS month,
-- Localized month name -- Localized month name
@@ -51,14 +51,14 @@ def upgrade():
FROM generate_series(0,365*50+10) AS SEQUENCE(DAY) FROM generate_series(0,365*50+10) AS SEQUENCE(DAY)
GROUP BY SEQUENCE.day GROUP BY SEQUENCE.day
) DQ ) DQ
ORDER BY local_date ORDER BY bst_date
); );
""" """
) )
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'service_id', 'service_id',
'rate_multiplier', 'rate_multiplier',
@@ -70,7 +70,7 @@ def downgrade():
# We don't downgrade populated data # We don't downgrade populated data
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'rate_multiplier', 'rate_multiplier',
'provider', 'provider',

View File

@@ -16,7 +16,7 @@ down_revision = '0183_alter_primary_key'
def upgrade(): def upgrade():
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'service_id', 'service_id',
'rate_multiplier', 'rate_multiplier',
@@ -28,7 +28,7 @@ def upgrade():
def downgrade(): def downgrade():
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'service_id', 'service_id',
'rate_multiplier', 'rate_multiplier',

View File

@@ -15,7 +15,7 @@ down_revision = '0187_another_letter_org'
def upgrade(): def upgrade():
op.create_table('ft_notification_status', op.create_table('ft_notification_status',
sa.Column('local_date', sa.Date(), nullable=False), sa.Column('bst_date', sa.Date(), nullable=False),
sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('job_id', postgresql.UUID(as_uuid=True), nullable=False), sa.Column('job_id', postgresql.UUID(as_uuid=True), nullable=False),
@@ -23,16 +23,16 @@ def upgrade():
sa.Column('key_type', sa.Text(), nullable=False), sa.Column('key_type', sa.Text(), nullable=False),
sa.Column('notification_status', sa.Text(), nullable=False), sa.Column('notification_status', sa.Text(), nullable=False),
sa.Column('notification_count', sa.Integer(), nullable=False), sa.Column('notification_count', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('local_date', 'template_id', 'service_id', 'job_id', 'notification_type', 'key_type', 'notification_status') sa.PrimaryKeyConstraint('bst_date', 'template_id', 'service_id', 'job_id', 'notification_type', 'key_type', 'notification_status')
) )
op.create_index(op.f('ix_ft_notification_status_local_date'), 'ft_notification_status', ['local_date'], unique=False) op.create_index(op.f('ix_ft_notification_status_bst_date'), 'ft_notification_status', ['bst_date'], unique=False)
op.create_index(op.f('ix_ft_notification_status_job_id'), 'ft_notification_status', ['job_id'], unique=False) op.create_index(op.f('ix_ft_notification_status_job_id'), 'ft_notification_status', ['job_id'], unique=False)
op.create_index(op.f('ix_ft_notification_status_service_id'), 'ft_notification_status', ['service_id'], unique=False) op.create_index(op.f('ix_ft_notification_status_service_id'), 'ft_notification_status', ['service_id'], unique=False)
op.create_index(op.f('ix_ft_notification_status_template_id'), 'ft_notification_status', ['template_id'], unique=False) op.create_index(op.f('ix_ft_notification_status_template_id'), 'ft_notification_status', ['template_id'], unique=False)
def downgrade(): def downgrade():
op.drop_index(op.f('ix_ft_notification_status_local_date'), table_name='ft_notification_status') op.drop_index(op.f('ix_ft_notification_status_bst_date'), table_name='ft_notification_status')
op.drop_index(op.f('ix_ft_notification_status_template_id'), table_name='ft_notification_status') op.drop_index(op.f('ix_ft_notification_status_template_id'), table_name='ft_notification_status')
op.drop_index(op.f('ix_ft_notification_status_service_id'), table_name='ft_notification_status') op.drop_index(op.f('ix_ft_notification_status_service_id'), table_name='ft_notification_status')
op.drop_index(op.f('ix_ft_notification_status_job_id'), table_name='ft_notification_status') op.drop_index(op.f('ix_ft_notification_status_job_id'), table_name='ft_notification_status')

View File

@@ -16,7 +16,7 @@ def upgrade():
op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey") op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey")
sql = """ALTER TABLE ft_billing ADD CONSTRAINT sql = """ALTER TABLE ft_billing ADD CONSTRAINT
ft_billing_pkey PRIMARY KEY ft_billing_pkey PRIMARY KEY
(local_date, template_id, service_id, rate_multiplier, provider, notification_type, international, rate)""" (bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international, rate)"""
op.execute(sql) op.execute(sql)
@@ -25,5 +25,5 @@ def downgrade():
op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey") op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey")
sql = """ALTER TABLE ft_billing ADD CONSTRAINT sql = """ALTER TABLE ft_billing ADD CONSTRAINT
ft_billing_pkey PRIMARY KEY ft_billing_pkey PRIMARY KEY
(local_date, template_id, service_id, rate_multiplier, provider, notification_type, international)""" (bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international)"""
op.execute(sql) op.execute(sql)

View File

@@ -15,7 +15,7 @@ down_revision = '0234_ft_billing_postage'
def upgrade(): def upgrade():
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'service_id', 'service_id',
'notification_type', 'notification_type',
@@ -29,7 +29,7 @@ def upgrade():
def downgrade(): def downgrade():
op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
op.alter_column('ft_billing', 'postage', nullable=True) op.alter_column('ft_billing', 'postage', nullable=True)
op.create_primary_key('ft_billing_pkey', 'ft_billing', ['local_date', op.create_primary_key('ft_billing_pkey', 'ft_billing', ['bst_date',
'template_id', 'template_id',
'service_id', 'service_id',
'notification_type', 'notification_type',

View File

@@ -14,14 +14,14 @@ down_revision = '0306_letter_rates_price_rise'
def upgrade(): def upgrade():
op.drop_index('ix_dm_datetime_local_date', table_name='dm_datetime') op.drop_index('ix_dm_datetime_bst_date', table_name='dm_datetime')
op.drop_index('ix_dm_datetime_yearmonth', table_name='dm_datetime') op.drop_index('ix_dm_datetime_yearmonth', table_name='dm_datetime')
op.drop_table('dm_datetime') op.drop_table('dm_datetime')
def downgrade(): def downgrade():
op.create_table('dm_datetime', op.create_table('dm_datetime',
sa.Column('local_date', sa.DATE(), autoincrement=False, nullable=False), sa.Column('bst_date', sa.DATE(), autoincrement=False, nullable=False),
sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('month_name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('month_name', sa.VARCHAR(), autoincrement=False, nullable=False),
@@ -37,7 +37,7 @@ def downgrade():
sa.Column('financial_year', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('financial_year', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('utc_daytime_start', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.Column('utc_daytime_start', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.Column('utc_daytime_end', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.Column('utc_daytime_end', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('local_date', name='dm_datetime_pkey') sa.PrimaryKeyConstraint('bst_date', name='dm_datetime_pkey')
) )
op.create_index('ix_dm_datetime_yearmonth', 'dm_datetime', ['year', 'month'], unique=False) op.create_index('ix_dm_datetime_yearmonth', 'dm_datetime', ['year', 'month'], unique=False)
op.create_index('ix_dm_datetime_local_date', 'dm_datetime', ['local_date'], unique=False) op.create_index('ix_dm_datetime_bst_date', 'dm_datetime', ['bst_date'], unique=False)

View File

@@ -15,16 +15,16 @@ down_revision = '0348_migrate_broadcast_settings'
def upgrade(): def upgrade():
op.create_table('ft_processing_time', op.create_table('ft_processing_time',
sa.Column('local_date', sa.Date(), nullable=False), sa.Column('bst_date', sa.Date(), nullable=False),
sa.Column('messages_total', sa.Integer(), nullable=False), sa.Column('messages_total', sa.Integer(), nullable=False),
sa.Column('messages_within_10_secs', sa.Integer(), nullable=False), sa.Column('messages_within_10_secs', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('local_date') sa.PrimaryKeyConstraint('bst_date')
) )
op.create_index(op.f('ix_ft_processing_time_local_date'), 'ft_processing_time', ['local_date'], unique=False) op.create_index(op.f('ix_ft_processing_time_bst_date'), 'ft_processing_time', ['bst_date'], unique=False)
def downgrade(): def downgrade():
op.drop_index(op.f('ix_ft_processing_time_local_date'), table_name='ft_processing_time') op.drop_index(op.f('ix_ft_processing_time_bst_date'), table_name='ft_processing_time')
op.drop_table('ft_processing_time') op.drop_table('ft_processing_time')

View File

@@ -24,8 +24,8 @@ def upgrade():
SET rate = 0.0161 SET rate = 0.0161
WHERE WHERE
notification_type = 'sms' AND notification_type = 'sms' AND
local_date >= '2022-04-01' AND bst_date >= '2022-04-01' AND
local_date < '2022-05-01' bst_date < '2022-05-01'
""" """
) )