db: INSERT IGNORE on schema_migrations to tolerate multi-worker boot race

This commit is contained in:
Sulkta 2026-04-28 19:49:40 -07:00
parent 48026aeae4
commit 00a4c71aa9

View file

@ -100,8 +100,10 @@ class DB:
if ver in done:
continue
cur.execute(sql)
# IGNORE to tolerate the multi-worker boot race where two
# gunicorn workers both bootstrap an empty migrations table
cur.execute(
"INSERT INTO schema_migrations (version) VALUES (%s)", (ver,)
"INSERT IGNORE INTO schema_migrations (version) VALUES (%s)", (ver,)
)
applied.append(ver)
return applied