fix: remove permanent server_default from download_token migration

This commit is contained in:
2026-03-01 15:59:20 +01:00
parent c55d73fd58
commit d6e3904f0a

View File

@@ -18,7 +18,7 @@ depends_on = None
def upgrade() -> None: def upgrade() -> None:
op.add_column( op.add_column(
"configs", "configs",
sa.Column("download_token", sa.String(64), nullable=False, server_default=""), sa.Column("download_token", sa.String(64), nullable=False, server_default="''"),
) )
# Backfill existing rows with unique tokens # Backfill existing rows with unique tokens
configs = table("configs", column("id", sa.Integer), column("download_token", sa.String(64))) configs = table("configs", column("id", sa.Integer), column("download_token", sa.String(64)))
@@ -29,6 +29,8 @@ def upgrade() -> None:
.where(configs.c.id == row.id) .where(configs.c.id == row.id)
.values(download_token=secrets.token_urlsafe(32)) .values(download_token=secrets.token_urlsafe(32))
) )
# Remove the DB-level default — ORM model provides Python-level default
op.alter_column("configs", "download_token", server_default=None)
def downgrade() -> None: def downgrade() -> None: