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

This commit is contained in:
Kayos 2026-04-28 19:49:40 -07:00
parent d333af014e
commit d3369bb141

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