Post.source_id refactor + tick/backfill modes + PARTIAL classifier + Mux fix + UX #44

Merged
bvandeusen merged 9 commits from dev into main 2026-06-01 20:44:24 -04:00
Showing only changes of commit 644d538bab - Show all commits
@@ -50,12 +50,14 @@ def upgrade() -> None:
conn = op.get_bind() conn = op.get_bind()
# Step 1: add Post.artist_id, initially nullable for backfill. # Step 1: add Post.artist_id, initially nullable for backfill.
# FK naming follows the Base.metadata naming_convention
# (fk_<table>_<column>_<referred_table>) — alembic 0001 set this up.
op.add_column( op.add_column(
"post", "post",
sa.Column("artist_id", sa.Integer, nullable=True), sa.Column("artist_id", sa.Integer, nullable=True),
) )
op.create_foreign_key( op.create_foreign_key(
"post_artist_id_fkey", "post", "artist", "fk_post_artist_id_artist", "post", "artist",
["artist_id"], ["id"], ondelete="CASCADE", ["artist_id"], ["id"], ondelete="CASCADE",
) )
@@ -82,22 +84,24 @@ def upgrade() -> None:
op.alter_column("post", "artist_id", nullable=False) op.alter_column("post", "artist_id", nullable=False)
op.create_index("ix_post_artist_id", "post", ["artist_id"]) op.create_index("ix_post_artist_id", "post", ["artist_id"])
# Step 4: relax post.source_id + flip FK to SET NULL. # Step 4: relax post.source_id + flip FK to SET NULL. The original FK
# name from alembic 0001 is `fk_post_source_id_source` per the
# NAMING_CONVENTION in models/base.py.
op.alter_column("post", "source_id", nullable=True) op.alter_column("post", "source_id", nullable=True)
op.drop_constraint("post_source_id_fkey", "post", type_="foreignkey") op.drop_constraint("fk_post_source_id_source", "post", type_="foreignkey")
op.create_foreign_key( op.create_foreign_key(
"post_source_id_fkey", "post", "source", "fk_post_source_id_source", "post", "source",
["source_id"], ["id"], ondelete="SET NULL", ["source_id"], ["id"], ondelete="SET NULL",
) )
# Step 5: relax image_provenance.source_id + flip FK to SET NULL. # Step 5: relax image_provenance.source_id + flip FK to SET NULL.
op.alter_column("image_provenance", "source_id", nullable=True) op.alter_column("image_provenance", "source_id", nullable=True)
op.drop_constraint( op.drop_constraint(
"image_provenance_source_id_fkey", "image_provenance", "fk_image_provenance_source_id_source", "image_provenance",
type_="foreignkey", type_="foreignkey",
) )
op.create_foreign_key( op.create_foreign_key(
"image_provenance_source_id_fkey", "image_provenance", "source", "fk_image_provenance_source_id_source", "image_provenance", "source",
["source_id"], ["id"], ondelete="SET NULL", ["source_id"], ["id"], ondelete="SET NULL",
) )