"""An explored channel someone follows is the catalog's own, and so are its videos Revision ID: 0116_followed_explored_channels Revises: 0115_takeout_channels Create Date: 2026-10-24 A follow pulled in from YouTube (the subscription import) left an explored channel flagged as an exploration's, and a subscribe landing while an exploration's videos came in left those videos flagged on a channel that no longer was one. Both are held in the code now; this clears what they left: the channel of a subscription is not an exploration's, and no video is an exploration's on a channel that is not one. Data only, so the downgrade has nothing to undo. """ from alembic import op revision: str = "0116_followed_explored_channels" down_revision: str | None = "0115_takeout_channels" branch_labels: str | None = None depends_on: str | None = None def upgrade() -> None: op.execute( "UPDATE channels SET from_explore = false WHERE from_explore" " AND EXISTS (SELECT 1 FROM subscriptions s WHERE s.channel_id = channels.id)" ) op.execute( "UPDATE videos SET via_explore = false WHERE via_explore" " AND channel_id IN (SELECT id FROM channels WHERE NOT from_explore)" ) def downgrade() -> None: pass