Add org types table

This commit is contained in:
Pea Tyczynska
2019-07-10 18:17:33 +01:00
parent 663ab6d96b
commit 9dfc550f46
9 changed files with 93 additions and 15 deletions

View File

@@ -0,0 +1,47 @@
"""
Revision ID: 0299_org_types_table
Revises: 0298_add_mou_signed_receipt
Create Date: 2019-07-10 16:07:22.019759
"""
from alembic import op
import sqlalchemy as sa
revision = '0299_org_types_table'
down_revision = '0298_add_mou_signed_receipt'
def upgrade():
organisation_types_table = op.create_table(
'organisation_types',
sa.Column('name', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('name'),
sa.Column('is_crown', sa.Boolean, nullable=True),
sa.Column('annual_free_sms_fragment_limit', sa.BigInteger, nullable=False)
)
op.bulk_insert(
organisation_types_table,
[
{'name': x, 'is_crown': y, 'annual_free_sms_fragment_limit': z} for x, y, z in [
["central", None, 250000],
["local", False, 25000],
["nhs_central", False, 250000],
["nhs_local", False, 25000],
["emergency_services", False, 25000],
["school_or_college", False, 25000],
["other", None, 25000],
]
]
)
op.alter_column('services', 'crown', nullable=True)
op.alter_column('services_history', 'crown', nullable=True)
def downgrade():
op.execute('DROP TABLE organisation_types')
op.alter_column('services', 'crown', nullable=False)
op.alter_column('services_history', 'crown', nullable=False)