Files
notifications-api/migrations/versions/0378_add_org_names.py

57 lines
1.9 KiB
Python
Raw Normal View History

"""
2022-10-11 20:38:00 +00:00
Revision ID: 0378_add_org_names
Revises: 0377_add_inbound_sms_number
Create Date: 2022-09-23 20:04:00.766980
"""
2024-04-01 15:12:33 -07:00
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
2023-08-29 14:54:30 -07:00
revision = "0378_add_org_names"
down_revision = "0377_add_inbound_sms_number"
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.get_bind()
# bluntly swap out data
2023-08-29 14:54:30 -07:00
op.execute(
"INSERT INTO organisation_types VALUES ('state','f','250000'),('federal','f','250000');"
)
op.execute("UPDATE services SET organisation_type = 'federal';")
op.execute("UPDATE organisation SET organisation_type = 'federal';")
op.execute("UPDATE services_history SET organisation_type = 'federal';")
2023-08-29 14:54:30 -07:00
# remove uk values
2023-11-17 09:47:32 -05:00
service_delete = """DELETE FROM organisation_types WHERE name IN
('central','local','nhs','nhs_central','nhs_local','emergency_service','school_or_college','nhs_gp')
"""
op.execute(service_delete)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
2023-11-17 09:47:32 -05:00
service_insert = """INSERT INTO organisation_types VALUES
('central','','250000')
('local','f','25000')
('nhs','','25000')
('nhs_central','t','250000')
('nhs_local','f','25000')
('emergency_service','f','25000')
('school_or_college','f','25000')
('nhs_gp','f','25000')
"""
op.execute(service_insert)
op.execute("UPDATE services SET organisation_type = 'central';")
op.execute("UPDATE organisation SET organisation_type = 'central';")
op.execute("UPDATE services_history SET organisation_type = 'central';")
op.execute("DELETE FROM organisation_types WHERE name IN ('federal','state')")
# ### end Alembic commands ###