Add postage column to ft_billing

Added a new varchar column, postage, to ft_billing. This is nullable and
not part of the composite primary key for now, but this will change
later.
This commit is contained in:
Katie Smith
2018-09-24 14:58:59 +01:00
parent 48db3a5e11
commit 0936060f5d
2 changed files with 23 additions and 0 deletions

View File

@@ -1811,6 +1811,7 @@ class FactBilling(db.Model):
rate_multiplier = db.Column(db.Integer(), nullable=False, primary_key=True)
international = db.Column(db.Boolean, nullable=False, primary_key=True)
rate = db.Column(db.Numeric(), nullable=False, primary_key=True)
postage = db.Column(db.String)
billable_units = db.Column(db.Integer(), nullable=True)
notifications_sent = db.Column(db.Integer(), nullable=True)
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)

View File

@@ -0,0 +1,22 @@
"""
Revision ID: 0234_ft_billing_postage
Revises: 0233_updated_first_class_dates
Create Date: 2018-09-28 14:43:26.100884
"""
from alembic import op
import sqlalchemy as sa
revision = '0234_ft_billing_postage'
down_revision = '0233_updated_first_class_dates'
def upgrade():
op.add_column('ft_billing', sa.Column('postage', sa.String(), nullable=True))
op.execute("UPDATE ft_billing SET postage = (CASE WHEN notification_type = 'letter' THEN 'second' ELSE 'none' END)")
def downgrade():
op.drop_column('ft_billing', 'postage')