From dcecd21f8237f9e455fa2aaf4862530470e7ffa8 Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Thu, 27 Jul 2017 13:47:35 +0100 Subject: [PATCH] Drop unused month and year columns from monthlybilling --- .../0114_drop_monthly_billing_cols.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 migrations/versions/0114_drop_monthly_billing_cols.py diff --git a/migrations/versions/0114_drop_monthly_billing_cols.py b/migrations/versions/0114_drop_monthly_billing_cols.py new file mode 100644 index 000000000..e02a0ef90 --- /dev/null +++ b/migrations/versions/0114_drop_monthly_billing_cols.py @@ -0,0 +1,34 @@ +""" + +Revision ID: 0014_drop_monthly_billing_cols +Revises: 0113_job_created_by_nullable +Create Date: 2017-07-27 13:36:37.304344 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0014_drop_monthly_billing_cols' +down_revision = '0113_job_created_by_nullable' + + +def upgrade(): + op.drop_index('uix_monthly_billing', table_name='monthly_billing') + op.create_unique_constraint( + 'uix_monthly_billing', 'monthly_billing', ['service_id', 'start_date', 'notification_type'] + ) + op.drop_column('monthly_billing', 'year') + op.drop_column('monthly_billing', 'month') + + +def downgrade(): + op.add_column('monthly_billing', sa.Column('month', sa.VARCHAR(), autoincrement=False, nullable=True)) + op.add_column( + 'monthly_billing', + sa.Column('year', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True) + ) + op.drop_constraint('uix_monthly_billing', 'monthly_billing', type_='unique') + op.create_index( + 'uix_monthly_billing', 'monthly_billing', ['service_id', 'start_date', 'notification_type'], unique=True + )