Public Access
66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
"""Add recipe catalog quarantine state.
|
|
|
|
Revision ID: 0018
|
|
Revises: 0017
|
|
Create Date: 2026-08-14
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
|
|
revision: str = "0018"
|
|
down_revision: Union[str, None] = "0017"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
recipe_catalog_status_enum = postgresql.ENUM(
|
|
"active",
|
|
"quarantined",
|
|
name="recipe_catalog_status_enum",
|
|
create_type=False,
|
|
)
|
|
|
|
|
|
def upgrade() -> None:
|
|
recipe_catalog_status_enum.create(op.get_bind(), checkfirst=True)
|
|
op.add_column(
|
|
"recipe",
|
|
sa.Column(
|
|
"catalog_status",
|
|
recipe_catalog_status_enum,
|
|
nullable=False,
|
|
server_default="active",
|
|
),
|
|
)
|
|
op.add_column(
|
|
"recipe",
|
|
sa.Column(
|
|
"catalog_findings",
|
|
postgresql.JSONB(),
|
|
nullable=False,
|
|
server_default=sa.text("'[]'::jsonb"),
|
|
),
|
|
)
|
|
op.add_column(
|
|
"recipe",
|
|
sa.Column("catalog_reviewed_at", sa.DateTime(timezone=True), nullable=True),
|
|
)
|
|
op.create_index(
|
|
"ix_recipe_catalog_status",
|
|
"recipe",
|
|
["catalog_status"],
|
|
unique=False,
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_recipe_catalog_status", table_name="recipe")
|
|
op.drop_column("recipe", "catalog_reviewed_at")
|
|
op.drop_column("recipe", "catalog_findings")
|
|
op.drop_column("recipe", "catalog_status")
|
|
recipe_catalog_status_enum.drop(op.get_bind(), checkfirst=True)
|