Skip to content

Commit 1ec0db9

Browse files
matteiusclaude
andcommitted
fix(mfa-1): bind seed-migration UUID with sa.Uuid type to satisfy asyncpg/postgres
T22's seed migration shipped with id=str(uuid.uuid4()), which asyncpg renders as VARCHAR and Postgres rejects against the uuid-typed id column with DatatypeMismatchError. The whole migration block (T5 + T22) ran in one transaction so the failure rolled back T5's MFA tables too — production boot went into a crashloop on the new image. Fix: use sa.bindparam with explicit sa.Uuid() type so the parameter is rendered as a real postgres uuid and stays cross-dialect. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bf77ad2 commit 1ec0db9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎fief/alembic/versions/2026-05-09b_seed_mfa_email_templates.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ def upgrade():
7070
).first()
7171
if existing is not None:
7272
continue
73+
# Bind id with explicit Uuid type so asyncpg renders it as the
74+
# postgres uuid type (not VARCHAR). The bare str() form failed in
75+
# production with DatatypeMismatchError.
7376
bind.execute(
7477
sa.text(
7578
f"INSERT INTO {table} "
7679
"(id, created_at, updated_at, type, subject, content) "
7780
"VALUES (:id, :created_at, :updated_at, :t, :s, :c)"
7881
).bindparams(
79-
id=str(uuid.uuid4()),
82+
sa.bindparam("id", value=uuid.uuid4(), type_=sa.Uuid()),
8083
created_at=now,
8184
updated_at=now,
8285
t=type_,

0 commit comments

Comments
 (0)