mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Add and populate crown column to services and services_history
- Added the boolean 'crown' column to services and services_history tables - We populate this column in the same migration script by checking the 'organisation_type' of a service
This commit is contained in:
42
migrations/versions/0149_add_crown_to_services.py
Normal file
42
migrations/versions/0149_add_crown_to_services.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0149_add_crown_column_to_services
|
||||
Revises: 0148_add_letters_as_pdf_svc_perm
|
||||
Create Date: 2017-12-04 12:13:35.268712
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0149_add_crown_to_services'
|
||||
down_revision = '0148_add_letters_as_pdf_svc_perm'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('services', sa.Column('crown', sa.Boolean(), nullable=True))
|
||||
op.execute("""
|
||||
update services set crown = True
|
||||
where organisation_type = 'central'
|
||||
""")
|
||||
op.execute("""
|
||||
update services set crown = False
|
||||
where crown is null
|
||||
""")
|
||||
op.alter_column('services', 'crown', nullable=False)
|
||||
|
||||
op.add_column('services_history', sa.Column('crown', sa.Boolean(), nullable=True))
|
||||
op.execute("""
|
||||
update services_history set crown = True
|
||||
where organisation_type = 'central'
|
||||
""")
|
||||
op.execute("""
|
||||
update services_history set crown = False
|
||||
where crown is null
|
||||
""")
|
||||
op.alter_column('services_history', 'crown', nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('services', 'crown')
|
||||
op.drop_column('services_history', 'crown')
|
||||
Reference in New Issue
Block a user