This reverts 2529b51. Not a retreat — a reordering, on the operator's
call, and the better sequence.
The squash's acceptance test (run 4971) found ~130 places where the ORM
models do not describe the deployed schema (#3275), including a
unique=True the database never had and two UNIQUE indexes that exist
only in migrations. Collapsing now would have baked all of that into the
one file a public installer starts from.
So: fix the drift first as ordinary migrations on the intact chain, let
the operator deploy so their database moves to the corrected head, and
only then collapse. The baseline is then generated from reconciled
models and reproduces a schema worth reproducing.
Nothing is lost by reverting. The baseline was never deployed, and
regenerating it after the fixes is strictly better than patching this
copy — it will come out of autogenerate correct rather than needing the
same hand-finishing twice.
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
"""retire the Camie tagger + allowlist bulk-apply (#1189)
|
|
|
|
The v2 pivot made heads + CCIP the tag source and head auto-apply the earned
|
|
propagation. The Camie tagger ran only to feed the allowlist bulk-apply (its
|
|
predictions had no other consumer), and the allowlist was a second, un-earned
|
|
auto-apply path parallel to heads. Both are retired — drop their storage.
|
|
|
|
(image_prediction = Camie's per-image predictions; tag_allowlist = the bulk-
|
|
apply allowlist. Nothing references INTO these tables, so the drop is clean.)
|
|
|
|
Revision ID: 0067
|
|
Revises: 0066
|
|
Create Date: 2026-06-30
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0067"
|
|
down_revision: Union[str, None] = "0066"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.drop_table("image_prediction")
|
|
op.drop_table("tag_allowlist")
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.create_table(
|
|
"tag_allowlist",
|
|
sa.Column("tag_id", sa.Integer(), nullable=False),
|
|
sa.Column(
|
|
"min_confidence", sa.Float(), nullable=False, server_default="0.9"
|
|
),
|
|
sa.Column(
|
|
"created_at", sa.DateTime(timezone=True),
|
|
server_default=sa.func.now(), nullable=False,
|
|
),
|
|
sa.ForeignKeyConstraint(["tag_id"], ["tag.id"], ondelete="CASCADE"),
|
|
sa.PrimaryKeyConstraint("tag_id"),
|
|
sa.CheckConstraint(
|
|
"min_confidence >= 0 AND min_confidence <= 1",
|
|
name="ck_tag_allowlist_confidence_range",
|
|
),
|
|
)
|
|
op.create_table(
|
|
"image_prediction",
|
|
sa.Column("id", sa.Integer(), primary_key=True),
|
|
sa.Column("image_record_id", sa.Integer(), nullable=False),
|
|
sa.Column("raw_name", sa.String(length=255), nullable=False),
|
|
sa.Column("category", sa.String(length=32), nullable=False),
|
|
sa.Column("score", sa.Float(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["image_record_id"], ["image_record.id"], ondelete="CASCADE"
|
|
),
|
|
)
|
|
op.create_index(
|
|
"ix_image_prediction_image", "image_prediction", ["image_record_id"]
|
|
)
|
|
op.create_index(
|
|
"ix_image_prediction_name_score", "image_prediction",
|
|
["raw_name", "score"],
|
|
)
|