diff --git a/migrations/versions/0174_add_billing_facts.py b/migrations/versions/0174_add_billing_facts.py index 9b3878b1d..ab108e3a8 100644 --- a/migrations/versions/0174_add_billing_facts.py +++ b/migrations/versions/0174_add_billing_facts.py @@ -16,7 +16,7 @@ down_revision = '0173_create_daily_sorted_letter' def upgrade(): # Create notifications_for_today table 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('service_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('billable_units', sa.Numeric(), nullable=True), sa.Column('notifications_sent', sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint('local_date', 'template_id') + sa.PrimaryKeyConstraint('bst_date', 'template_id') ) # 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) # Create dm_datetime table 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('month', sa.Integer(), 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('utc_daytime_start', sa.DateTime(), nullable=False), sa.Column('utc_daytime_end', sa.DateTime(), nullable=False), - sa.PrimaryKeyConstraint('local_date') + sa.PrimaryKeyConstraint('bst_date') ) # 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_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 op.execute( """ INSERT into dm_datetime ( SELECT - datum AS local_date, + datum AS bst_date, EXTRACT(YEAR FROM datum) AS year, EXTRACT(MONTH FROM datum) AS month, -- Localized month name @@ -91,7 +91,7 @@ def upgrade(): FROM generate_series(0,365*50+10) AS SEQUENCE(DAY) GROUP BY SEQUENCE.day ) DQ - ORDER BY local_date + ORDER BY bst_date ); """ ) diff --git a/migrations/versions/0179_billing_primary_const.py b/migrations/versions/0179_billing_primary_const.py index 9356b5fc9..ab5b49739 100644 --- a/migrations/versions/0179_billing_primary_const.py +++ b/migrations/versions/0179_billing_primary_const.py @@ -20,7 +20,7 @@ def upgrade(): op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') # These are the orthogonal dimensions that define a row (except international). # 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', 'rate_multiplier', '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('crown', sa.TEXT(), autoincrement=False, nullable=True)) 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']) diff --git a/migrations/versions/0181_billing_primary_key.py b/migrations/versions/0181_billing_primary_key.py index dea8eeafc..eec3c4950 100644 --- a/migrations/versions/0181_billing_primary_key.py +++ b/migrations/versions/0181_billing_primary_key.py @@ -19,7 +19,7 @@ def upgrade(): nullable=False) 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', 'rate_multiplier', 'provider', @@ -34,7 +34,7 @@ def downgrade(): 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', 'rate_multiplier', 'provider', diff --git a/migrations/versions/0183_alter_primary_key.py b/migrations/versions/0183_alter_primary_key.py index ad26e4081..a183f9562 100644 --- a/migrations/versions/0183_alter_primary_key.py +++ b/migrations/versions/0183_alter_primary_key.py @@ -24,7 +24,7 @@ def upgrade(): """ INSERT into dm_datetime ( SELECT - datum AS local_date, + datum AS bst_date, EXTRACT(YEAR FROM datum) AS year, EXTRACT(MONTH FROM datum) AS month, -- Localized month name @@ -51,14 +51,14 @@ def upgrade(): FROM generate_series(0,365*50+10) AS SEQUENCE(DAY) GROUP BY SEQUENCE.day ) DQ - ORDER BY local_date + ORDER BY bst_date ); """ ) 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', 'service_id', 'rate_multiplier', @@ -70,7 +70,7 @@ def downgrade(): # We don't downgrade populated data 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', 'rate_multiplier', 'provider', diff --git a/migrations/versions/0184_alter_primary_key_1.py b/migrations/versions/0184_alter_primary_key_1.py index 0837995a7..0dc343f45 100644 --- a/migrations/versions/0184_alter_primary_key_1.py +++ b/migrations/versions/0184_alter_primary_key_1.py @@ -16,7 +16,7 @@ down_revision = '0183_alter_primary_key' def upgrade(): 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', 'service_id', 'rate_multiplier', @@ -28,7 +28,7 @@ def upgrade(): def downgrade(): 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', 'service_id', 'rate_multiplier', diff --git a/migrations/versions/0188_add_ft_notification_status.py b/migrations/versions/0188_add_ft_notification_status.py index 97432d6eb..403735837 100644 --- a/migrations/versions/0188_add_ft_notification_status.py +++ b/migrations/versions/0188_add_ft_notification_status.py @@ -15,7 +15,7 @@ down_revision = '0187_another_letter_org' def upgrade(): 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('service_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('notification_status', sa.Text(), 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_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) 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_service_id'), table_name='ft_notification_status') op.drop_index(op.f('ix_ft_notification_status_job_id'), table_name='ft_notification_status') diff --git a/migrations/versions/0191_ft_billing_pkey.py b/migrations/versions/0191_ft_billing_pkey.py index b3ad5d839..80093083c 100644 --- a/migrations/versions/0191_ft_billing_pkey.py +++ b/migrations/versions/0191_ft_billing_pkey.py @@ -16,7 +16,7 @@ def upgrade(): op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey") sql = """ALTER TABLE ft_billing ADD CONSTRAINT 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) @@ -25,5 +25,5 @@ def downgrade(): op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey") sql = """ALTER TABLE ft_billing ADD CONSTRAINT 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) \ No newline at end of file diff --git a/migrations/versions/0235_add_postage_to_pk.py b/migrations/versions/0235_add_postage_to_pk.py index 13506a081..072f2646e 100644 --- a/migrations/versions/0235_add_postage_to_pk.py +++ b/migrations/versions/0235_add_postage_to_pk.py @@ -15,7 +15,7 @@ down_revision = '0234_ft_billing_postage' def upgrade(): 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', 'service_id', 'notification_type', @@ -29,7 +29,7 @@ def upgrade(): def downgrade(): op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary') 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', 'service_id', 'notification_type', diff --git a/migrations/versions/0307_delete_dm_datetime.py b/migrations/versions/0307_delete_dm_datetime.py index 5fdc79bb6..a4b664920 100644 --- a/migrations/versions/0307_delete_dm_datetime.py +++ b/migrations/versions/0307_delete_dm_datetime.py @@ -14,14 +14,14 @@ down_revision = '0306_letter_rates_price_rise' 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_table('dm_datetime') def downgrade(): 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('month', sa.INTEGER(), 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('utc_daytime_start', 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_local_date', 'dm_datetime', ['local_date'], unique=False) + op.create_index('ix_dm_datetime_bst_date', 'dm_datetime', ['bst_date'], unique=False) diff --git a/migrations/versions/0349_add_ft_processing_time.py b/migrations/versions/0349_add_ft_processing_time.py index 5a938f9e2..df0a613cd 100644 --- a/migrations/versions/0349_add_ft_processing_time.py +++ b/migrations/versions/0349_add_ft_processing_time.py @@ -15,16 +15,16 @@ down_revision = '0348_migrate_broadcast_settings' def upgrade(): 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_within_10_secs', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=False), 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(): - 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') diff --git a/migrations/versions/0371_fix_apr_2022_sms_rate.py b/migrations/versions/0371_fix_apr_2022_sms_rate.py index 144a7c76d..62c9fe980 100644 --- a/migrations/versions/0371_fix_apr_2022_sms_rate.py +++ b/migrations/versions/0371_fix_apr_2022_sms_rate.py @@ -24,8 +24,8 @@ def upgrade(): SET rate = 0.0161 WHERE notification_type = 'sms' AND - local_date >= '2022-04-01' AND - local_date < '2022-05-01' + bst_date >= '2022-04-01' AND + bst_date < '2022-05-01' """ )