|
- <%
- '=======================================================================================================================
- ' MIGRATION: create_embedding_index_table
- '=======================================================================================================================
- ' Bookkeeping for semantic (vector) indexing (spec FR-008): one row per indexed memory or chunk. The vectors live in
- ' the vector store (Qdrant, derived data); this table records what should be there, for which revision, with which
- ' model/dimensions, and whether it succeeded, so a failed or stale index can always be rebuilt from SQLite.
- ' status: pending (needs embedding), indexed, failed (attempts counts retries), delete (point must be removed)
- '-----------------------------------------------------------------------------------------------------------------------
- Sub Migration_Up(migration)
- migration.ExecuteSQL "CREATE TABLE embedding_index (" & _
- "target_kind TEXT NOT NULL CHECK (target_kind IN ('memory','chunk')), " & _
- "target_id TEXT NOT NULL, " & _
- "tenant_id TEXT NOT NULL, " & _
- "namespace_id TEXT NOT NULL, " & _
- "revision INTEGER NOT NULL, " & _
- "status TEXT NOT NULL CHECK (status IN ('pending','indexed','failed','delete')), " & _
- "model TEXT, " & _
- "dimensions INTEGER, " & _
- "attempts INTEGER NOT NULL DEFAULT 0, " & _
- "error TEXT, " & _
- "updated_at TEXT NOT NULL, " & _
- "PRIMARY KEY (target_kind, target_id))"
- migration.CreateIndex "idx_embedding_index_status", "embedding_index", "status, tenant_id"
- migration.CreateIndex "idx_embedding_index_tenant", "embedding_index", "tenant_id"
- End Sub
-
- Sub Migration_Down(migration)
- migration.DropIndex "idx_embedding_index_tenant", "embedding_index"
- migration.DropIndex "idx_embedding_index_status", "embedding_index"
- migration.DropTable "embedding_index"
- End Sub
- %>
|