mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
Create a new table to warehouse the monthly billing numbers
This commit is contained in:
37
migrations/versions/0109_monthly_billing.py
Normal file
37
migrations/versions/0109_monthly_billing.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0109_monthly_billing
|
||||
Revises: 0108_change_logo_not_nullable
|
||||
Create Date: 2017-07-13 14:35:03.183659
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0109_monthly_billing'
|
||||
down_revision = '0108_change_logo_not_nullable'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
|
||||
op.create_table('monthly_billing',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('month', sa.String(), nullable=False),
|
||||
sa.Column('year', sa.Float(), nullable=False),
|
||||
sa.Column('notification_type',
|
||||
postgresql.ENUM('email', 'sms', 'letter', name='notification_type', create_type=False),
|
||||
nullable=False),
|
||||
sa.Column('monthly_totals', postgresql.JSON(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_monthly_billing_service_id'), 'monthly_billing', ['service_id'], unique=False)
|
||||
op.create_index(op.f('uix_monthly_billing'), 'monthly_billing', ['service_id', 'month', 'year', 'notification_type'], unique=True)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('monthly_billing')
|
||||
Reference in New Issue
Block a user