From 6ee9ca6a33dffd5f3486e1718f7a946cd5af1ff7 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 1 Oct 2026 21:28:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(migration):=20089=20revision=20id=20?= =?UTF-8?q?=E7=BC=A9=E7=9F=AD=E5=88=B0=2021=20=E5=AD=97=E7=AC=A6=20+=20ale?= =?UTF-8?q?mbic=5Fversion=20=E6=89=A9=20VARCHAR(256)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 revision id 36 字符超过 alembic_version.version_num VARCHAR(32), 迁移事务回滚导致列加不上、版本号也没更新。现在用短名 089_viral_video_cols(21 字符), 同时把 alembic_version.version_num 扩成 VARCHAR(256) 一劳永逸防未来再踩坑。 --- ...storyboard_backfill.py => 089_viral_video_cols.py} | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) rename alembic/versions/{089_viral_video_storyboard_backfill.py => 089_viral_video_cols.py} (83%) diff --git a/alembic/versions/089_viral_video_storyboard_backfill.py b/alembic/versions/089_viral_video_cols.py similarity index 83% rename from alembic/versions/089_viral_video_storyboard_backfill.py rename to alembic/versions/089_viral_video_cols.py index 1f0786919..31e45382f 100644 --- a/alembic/versions/089_viral_video_storyboard_backfill.py +++ b/alembic/versions/089_viral_video_cols.py @@ -1,6 +1,6 @@ """viral video add storyboard + generated_copy_text (complement 088) -Revision ID: 089_viral_video_storyboard_backfill +Revision ID: 089_viral_video_cols Revises: 088_viral_video_copy_result Create Date: 2026-10-01 @@ -14,13 +14,19 @@ import sqlalchemy as sa from alembic import op -revision = "089_viral_video_storyboard_backfill" +revision = "089_viral_video_cols" down_revision = "088_viral_video_copy_result" branch_labels = None depends_on = None def upgrade() -> None: + # 扩展 alembic_version.version_num 字段长度(原来 VARCHAR(32) 装不下长 revision id) + conn = op.get_bind() + try: + conn.execute(sa.text("ALTER TABLE alembic_version ALTER COLUMN version_num TYPE VARCHAR(256)")) + except Exception: + pass cols = [ ("storyboard", "JSON"), ("generated_copy_text", "TEXT NOT NULL DEFAULT ''"), @@ -30,7 +36,6 @@ def upgrade() -> None: ("video_model", "VARCHAR(100) NOT NULL DEFAULT ''"), ("copy_result", "JSON"), ] - conn = op.get_bind() for name, ddl in cols: try: conn.execute(sa.text(f"ALTER TABLE viral_video_jobs ADD COLUMN IF NOT EXISTS {name} {ddl}"))