Fix: needs_dog_selection TEXT '0' war truthy — INTEGER + === 1 Check (SW by-v946)
This commit is contained in:
parent
3b666c545f
commit
1ea8127aaf
4 changed files with 16 additions and 10 deletions
|
|
@ -2153,16 +2153,22 @@ def _migrate(conn_factory):
|
|||
pass
|
||||
|
||||
# ---- Feature: Subscription-Laufzeit & Kündigung ----
|
||||
for col, default in [
|
||||
("subscription_expires_at", "NULL"),
|
||||
("subscription_cancelled_at","NULL"),
|
||||
("needs_dog_selection", "0"),
|
||||
for col, typedef in [
|
||||
("subscription_expires_at", "TEXT DEFAULT NULL"),
|
||||
("subscription_cancelled_at", "TEXT DEFAULT NULL"),
|
||||
("needs_dog_selection", "INTEGER DEFAULT 0"),
|
||||
]:
|
||||
try:
|
||||
conn.execute(f"ALTER TABLE users ADD COLUMN {col} TEXT DEFAULT {default}")
|
||||
conn.execute(f"ALTER TABLE users ADD COLUMN {col} {typedef}")
|
||||
logger.info(f"Migration: {col} hinzugefügt.")
|
||||
except Exception:
|
||||
pass
|
||||
# Bestehende TEXT-Werte für needs_dog_selection auf 0/1 normalisieren
|
||||
try:
|
||||
conn.execute("UPDATE users SET needs_dog_selection=0 WHERE needs_dog_selection='0' OR needs_dog_selection IS NULL")
|
||||
conn.execute("UPDATE users SET needs_dog_selection=1 WHERE needs_dog_selection='1'")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# exercise_progress + training_plan_progress: dog_id ergänzen
|
||||
existing_ep = [r[1] for r in conn.execute("PRAGMA table_info(exercise_progress)").fetchall()]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue