From b66d6a6fe689e189dc71e36124e29b41136f77e1 Mon Sep 17 00:00:00 2001 From: Machiel Date: Fri, 16 Oct 2026 19:44:04 +0200 Subject: [PATCH] Migraties bij het starten met een bestandsslot: twee gunicorn-workers voegden tegelijk dezelfde kolom toe (duplicate column name) Co-Authored-By: Claude Opus 5.5 --- app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app.py b/app.py index 41dc9dd..a374c0d 100644 --- a/app.py +++ b/app.py @@ -7,6 +7,7 @@ Demoleads: python app.py demo (standaardmodellen uit demo/modellen al __version__ = '0.0.7' import csv +import fcntl import hashlib import hmac import io @@ -236,6 +237,14 @@ def migrate_documents(con): def init_db(): + """Schema en migraties; met een bestandsslot, want elke gunicorn-worker start dit bij het laden (anders voegen + twee workers dezelfde kolom toe of migreren ze dubbel).""" + with open(os.path.join(DATA, '.init.lock'), 'w') as lock: + fcntl.flock(lock, fcntl.LOCK_EX) + _init_db() + + +def _init_db(): con = sqlite3.connect(DB_PATH) with open(os.path.join(BASE, 'schema.sql')) as f: con.executescript(f.read())