From 4753ea809b0dae735fcfaba94d945c9b4b44b3d0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Mon, 2 Feb 2026 17:56:47 -0800 Subject: [PATCH] feat(migrations): make podcast file_location nullable --- .../89_make_podcast_file_location_nullable.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 surfsense_backend/alembic/versions/89_make_podcast_file_location_nullable.py diff --git a/surfsense_backend/alembic/versions/89_make_podcast_file_location_nullable.py b/surfsense_backend/alembic/versions/89_make_podcast_file_location_nullable.py new file mode 100644 index 000000000..1f011d153 --- /dev/null +++ b/surfsense_backend/alembic/versions/89_make_podcast_file_location_nullable.py @@ -0,0 +1,46 @@ +"""Make podcast file_location nullable + +Revision ID: 89 +Revises: 88 +Create Date: 2026-02-03 + +The podcast workflow creates a podcast record with PENDING status first, +then fills in the file_location after audio generation completes. This requires +file_location to be nullable. +""" + +from collections.abc import Sequence + +from alembic import op + +revision: str = "89" +down_revision: str | None = "88" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + # Make file_location nullable + op.execute( + """ + ALTER TABLE podcasts + ALTER COLUMN file_location DROP NOT NULL; + """ + ) + + +def downgrade() -> None: + # Set empty string for any NULL values before adding NOT NULL constraint + op.execute( + """ + UPDATE podcasts + SET file_location = '' + WHERE file_location IS NULL; + """ + ) + op.execute( + """ + ALTER TABLE podcasts + ALTER COLUMN file_location SET NOT NULL; + """ + )