progress on removing postage

This commit is contained in:
stvnrlly
2023-02-10 15:04:59 -05:00
parent 590b3356a1
commit ff3f2c06c0
40 changed files with 189 additions and 798 deletions

View File

@@ -1,6 +1,6 @@
"""
Revision ID: 1358d15190ba
Revision ID: 0384_remove_letter_branding_
Revises: 0383_update_default_templates.py
Create Date: 2023-02-09 22:24:07.187569
@@ -9,7 +9,7 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '1358d15190ba'
revision = '0384_remove_letter_branding_'
down_revision = '0383_update_default_templates.py'

View File

@@ -0,0 +1,150 @@
"""
Revision ID: 0385_remove postage_.py
Revises: 0384_remove_letter_branding_
Create Date: 2023-02-10 12:20:39.411493
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '0385_remove postage_.py'
down_revision = '0384_remove_letter_branding_'
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
# we need to replace the entire notifications_all_time_view in order to update it
op.execute("DROP VIEW notifications_all_time_view;")
op.execute("""
CREATE VIEW notifications_all_time_view AS
(
SELECT
id,
job_id,
job_row_number,
service_id,
template_id,
template_version,
api_key_id,
key_type,
billable_units,
notification_type,
created_at,
sent_at,
sent_by,
updated_at,
notification_status,
reference,
client_reference,
international,
phone_prefix,
rate_multiplier,
created_by_id,
document_download_count
FROM notifications
) UNION
(
SELECT
id,
job_id,
job_row_number,
service_id,
template_id,
template_version,
api_key_id,
key_type,
billable_units,
notification_type,
created_at,
sent_at,
sent_by,
updated_at,
notification_status,
reference,
client_reference,
international,
phone_prefix,
rate_multiplier,
created_by_id,
document_download_count
FROM notification_history
)
""")
op.drop_column('notification_history', 'postage')
op.drop_column('notifications', 'postage')
op.drop_column('templates', 'postage')
op.drop_column('templates_history', 'postage')
op.drop_column('ft_billing', 'postage')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('ft_billing', sa.Column('postage', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('templates_history', sa.Column('postage', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('templates', sa.Column('postage', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('notifications', sa.Column('postage', sa.VARCHAR(), autoincrement=False, nullable=True))
op.add_column('notification_history', sa.Column('postage', sa.VARCHAR(), autoincrement=False, nullable=True))
op.execute("DROP VIEW notifications_all_time_view;")
op.execute("""
CREATE VIEW notifications_all_time_view AS
(
SELECT
id,
job_id,
job_row_number,
service_id,
template_id,
template_version,
api_key_id,
key_type,
billable_units,
notification_type,
created_at,
sent_at,
sent_by,
updated_at,
notification_status,
reference,
client_reference,
international,
phone_prefix,
rate_multiplier,
postage,
created_by_id,
document_download_count
FROM notifications
) UNION
(
SELECT
id,
job_id,
job_row_number,
service_id,
template_id,
template_version,
api_key_id,
key_type,
billable_units,
notification_type,
created_at,
sent_at,
sent_by,
updated_at,
notification_status,
reference,
client_reference,
international,
phone_prefix,
rate_multiplier,
postage,
created_by_id,
document_download_count
FROM notification_history
)
""")
# ### end Alembic commands ###