51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
"""a doctor or chemist added by an MR waits for the Area Manager; a doctor visit records a gift
|
|
|
|
Every existing doctor and chemist is already in use, so all of them start APPROVED.
|
|
|
|
Revision ID: r8b4d0f6a3c5
|
|
Revises: q7a3c9e5f2b4
|
|
Create Date: 2026-10-26
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision: str = "r8b4d0f6a3c5"
|
|
down_revision: str | None = "q7a3c9e5f2b4"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
MASTERS = ("doctor", "chemist")
|
|
|
|
|
|
def upgrade() -> None:
|
|
for table in MASTERS:
|
|
op.add_column(
|
|
table,
|
|
sa.Column("approval_status", sa.String(10), nullable=False, server_default="APPROVED"),
|
|
)
|
|
op.add_column(
|
|
table,
|
|
sa.Column(
|
|
"requested_by_user_id",
|
|
sa.UUID(),
|
|
sa.ForeignKey("user.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
),
|
|
)
|
|
op.add_column(table, sa.Column("rejection_reason", sa.String(500), nullable=True))
|
|
op.create_index(f"ix_{table}_approval_status", table, ["approval_status"])
|
|
op.add_column("doctor_call", sa.Column("gift", sa.String(200), nullable=True))
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_column("doctor_call", "gift")
|
|
for table in reversed(MASTERS):
|
|
op.drop_index(f"ix_{table}_approval_status", table_name=table)
|
|
op.drop_column(table, "rejection_reason")
|
|
op.drop_column(table, "requested_by_user_id")
|
|
op.drop_column(table, "approval_status")
|