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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c69c3773dc
commit
b66d6a6fe6
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user