54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""auto
|
|
|
|
Revision ID: 2515ed7e2966
|
|
Revises: 72853b8d2126
|
|
Create Date: 2026-08-07 14:49:26.409410+00:00
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlmodel # SQLModel renders AutoString() into migrations but adds no import
|
|
|
|
|
|
revision: str = '2515ed7e2966'
|
|
down_revision: Union[str, None] = '72853b8d2126'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
# Deliberately NOT schema-qualified: Inbox_Messages.application_status carries
|
|
# type.schema = None, so the ORM emits the type name unqualified and resolves it
|
|
# through search_path. Creating it as app.<name> would not match.
|
|
application_status = sa.Enum(
|
|
'PROCESS', 'PENDING', 'APPROVED', 'REJECTED', 'ONHOLD', 'CLOSED',
|
|
name='candidate_application_status',
|
|
)
|
|
|
|
|
|
def upgrade() -> None:
|
|
# op.add_column does NOT emit CREATE TYPE, so the ALTER below would fail with
|
|
# `type "candidate_application_status" does not exist`.
|
|
application_status.create(op.get_bind(), checkfirst=True)
|
|
# server_default is required, not cosmetic: the column is NOT NULL and every
|
|
# existing row would be null without it, which Postgres rejects outright.
|
|
op.add_column(
|
|
'inbox_messages',
|
|
sa.Column(
|
|
'application_status',
|
|
application_status,
|
|
nullable=False,
|
|
server_default='CLOSED',
|
|
),
|
|
schema='app',
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_column('inbox_messages', 'application_status', schema='app')
|
|
# drop_column leaves the TYPE behind; without this, re-running upgrade fails
|
|
# with `type "candidate_application_status" already exists`.
|
|
application_status.drop(op.get_bind(), checkfirst=True)
|