From b751c8112042d78afe48a83e686609f09e07d7c4 Mon Sep 17 00:00:00 2001 From: bruno Date: Tue, 27 Oct 2026 23:48:09 -0400 Subject: [PATCH] coffre ObsiGate Phase 4 (issue #22) : app/migrations.py --- app/migrations.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/migrations.py b/app/migrations.py index a7ba1f8..bbc9ee9 100644 --- a/app/migrations.py +++ b/app/migrations.py @@ -2076,3 +2076,31 @@ def _migration_draco_links(conn: sqlite3.Connection) -> None: ) """ ) + + +@register(52, "coffre ObsiGate (Phase 4) : workspace_id + coffre_reference sur agent_connectors") +def _migration_coffre_reference(conn: sqlite3.Connection) -> None: + """Migration 52 — références ObsiGate pour les connecteurs (issue #22). + + * ``workspace_id`` : le connecteur appartient à un workspace (NULL = + connecteur historique global, conservé tel quel — migration + opportuniste, pas de big-bang). + * ``coffre_reference`` : ``coffre:/`` (métadonnée, pas une + valeur) ; vide = jeton chiffré local historique. + Idempotente (gardée par ``columns()``), comme les migrations 32/34. + """ + cols = columns(conn, "agent_connectors") + if "workspace_id" not in cols: + conn.execute( + "ALTER TABLE agent_connectors " + "ADD COLUMN workspace_id INTEGER REFERENCES workspaces(id)" + ) + if "coffre_reference" not in cols: + conn.execute( + "ALTER TABLE agent_connectors " + "ADD COLUMN coffre_reference TEXT NOT NULL DEFAULT ''" + ) + conn.execute( + "CREATE INDEX IF NOT EXISTS idx_agent_connectors_workspace " + "ON agent_connectors(workspace_id)" + )