"""Drop AI remnants: photos.needs_review and the pgvector extension Revision ID: 0019_drop_ai_remnants Revises: 0018_photos_nextcloud_fileid Create Date: 2026-05-14 The vision pipeline has been removed entirely (no more classifier, no worker-vision service, no torch/onnxruntime/open-clip-torch deps). The `needs_review` boolean and its partial index were populated only by that classifier and have no remaining writers or readers. The pgvector extension was originally added by 0003_pgvector_embeddings for the embeddings table that 0012_strip_ai_pipeline dropped; the extension itself is now unused, and the next deploy switches the Postgres image from pgvector/pgvector:pg16 to plain postgres:16. The extension must be dropped *before* that image swap or the new container will fail to load existing CREATE EXTENSION declarations. """ from typing import Sequence, Union from alembic import op revision: str = "0019_drop_ai_remnants" down_revision: Union[str, None] = "0018_photos_nextcloud_fileid" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.execute("DROP INDEX IF EXISTS ix_photos_needs_review") op.execute("ALTER TABLE photos DROP COLUMN IF EXISTS needs_review") op.execute("DROP EXTENSION IF EXISTS vector") def downgrade() -> None: # Re-create the column as a no-op (data is gone). The pgvector # extension is intentionally NOT re-added — matches the precedent # set by 0012_strip_ai_pipeline for its dropped tables. op.execute( "ALTER TABLE photos ADD COLUMN IF NOT EXISTS needs_review " "BOOLEAN NOT NULL DEFAULT FALSE" ) op.execute( "CREATE INDEX IF NOT EXISTS ix_photos_needs_review " "ON photos(needs_review) WHERE needs_review" )