first commit
Build and deploy / build-and-push (push) Successful in 17s
Build and deploy / deploy (push) Successful in 10s

This commit is contained in:
william
2026-08-21 16:23:49 +02:00
committed by william
commit 3f4ebc4527
248 changed files with 10180 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import db
def ensure_flow_schema(slug):
conn = db.connect(slug)
conn.executescript(
"""
CREATE TABLE IF NOT EXISTS _flow_nodes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
screen_id INTEGER NOT NULL REFERENCES _screens(id) ON DELETE CASCADE,
node_type TEXT NOT NULL,
x REAL NOT NULL DEFAULT 40,
y REAL NOT NULL DEFAULT 40,
trigger_element_id INTEGER REFERENCES _screen_elements(id),
trigger_event TEXT,
cond_definition_id INTEGER,
cond_row_id INTEGER,
cond_field TEXT,
cond_field_type TEXT,
cond_operator TEXT,
cond_value TEXT,
action_type TEXT,
target_screen_id INTEGER REFERENCES _screens(id),
target_element_id INTEGER REFERENCES _screen_elements(id),
element_property TEXT,
element_value TEXT,
target_definition_id INTEGER,
target_row_id INTEGER,
target_field TEXT,
data_operation TEXT,
data_value TEXT
);
CREATE TABLE IF NOT EXISTS _flow_edges (
id INTEGER PRIMARY KEY AUTOINCREMENT,
screen_id INTEGER NOT NULL REFERENCES _screens(id) ON DELETE CASCADE,
from_node_id INTEGER NOT NULL REFERENCES _flow_nodes(id) ON DELETE CASCADE,
from_port TEXT NOT NULL DEFAULT 'out',
to_node_id INTEGER NOT NULL REFERENCES _flow_nodes(id) ON DELETE CASCADE
);
"""
)
# 2.4 — conditions combinées (ET/OU) : un nœud Condition peut tester
# PLUSIEURS champs à la fois plutôt qu'un seul. cond_clauses (JSON, une
# liste de clauses en plus de la clause "historique" cond_definition_id/
# cond_field/etc.) + cond_combinator ('et'/'ou') sont ajoutés en ALTER
# TABLE pour ne rien casser sur les jeux déjà créés — un nœud sans
# cond_clauses garde exactement son comportement d'avant (une seule
# comparaison), voir evaluateConditionNode() dans templates/play.html.
cols = {r["name"] for r in conn.execute("PRAGMA table_info(_flow_nodes)").fetchall()}
if "cond_clauses" not in cols:
conn.execute("ALTER TABLE _flow_nodes ADD COLUMN cond_clauses TEXT")
if "cond_combinator" not in cols:
conn.execute("ALTER TABLE _flow_nodes ADD COLUMN cond_combinator TEXT NOT NULL DEFAULT 'et'")
conn.commit()
conn.close()