Files
notifications-api/migrations/versions/0302_add_org_id_to_services.py

54 lines
1.4 KiB
Python
Raw Normal View History

"""
Revision ID: 0302_add_org_id_to_services
Revises: 0301_upload_letters_permission
Create Date: 2019-08-06 09:43:57.993510
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
2023-08-29 14:54:30 -07:00
revision = "0302_add_org_id_to_services"
down_revision = "0301_upload_letters_permission"
def upgrade():
2023-08-29 14:54:30 -07:00
op.add_column(
"services",
sa.Column("organisation_id", postgresql.UUID(as_uuid=True), nullable=True),
)
op.create_index(
op.f("ix_services_organisation_id"),
"services",
["organisation_id"],
unique=False,
)
op.create_foreign_key(
"fk_service_organisation",
"services",
"organisation",
["organisation_id"],
["id"],
)
op.add_column(
"services_history",
sa.Column("organisation_id", postgresql.UUID(as_uuid=True), nullable=True),
)
op.create_index(
op.f("ix_services_history_organisation_id"),
"services_history",
["organisation_id"],
unique=False,
)
def downgrade():
2023-08-29 14:54:30 -07:00
op.drop_index(
op.f("ix_services_history_organisation_id"), table_name="services_history"
)
op.drop_column("services_history", "organisation_id")
op.drop_constraint("fk_service_organisation", "services", type_="foreignkey")
op.drop_index(op.f("ix_services_organisation_id"), table_name="services")
op.drop_column("services", "organisation_id")