feat: independent TKG processing mechanism with operation logging
- Created src/core/tkg/ module with service, log, and models - Added tkg_operation_log table for tracking all TKG operations - TkgService: build, rebuild (with force option), delete, get_operations - Updated rebuild endpoint with force parameter - Added GET /api/v1/file/:file_uuid/tkg for operation history - Added DELETE /api/v1/file/:file_uuid/tkg for TKG deletion - TKG rebuild now always triggers Rule 2 (even with 0 edges) - Full audit trail for all TKG operations (create/update/delete/rebuild)
This commit is contained in:
@@ -1324,6 +1324,29 @@ impl PostgresDb {
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
// ── TKG Operation Log ──
|
||||
sqlx::query("CREATE TABLE IF NOT EXISTS tkg_operation_log (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
file_uuid VARCHAR(32) NOT NULL,
|
||||
operation VARCHAR(20) NOT NULL,
|
||||
node_type VARCHAR(50),
|
||||
edge_type VARCHAR(50),
|
||||
nodes_created INT DEFAULT 0,
|
||||
nodes_updated INT DEFAULT 0,
|
||||
nodes_deleted INT DEFAULT 0,
|
||||
edges_created INT DEFAULT 0,
|
||||
edges_updated INT DEFAULT 0,
|
||||
edges_deleted INT DEFAULT 0,
|
||||
status VARCHAR(20) DEFAULT 'pending',
|
||||
error_message TEXT,
|
||||
started_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
completed_at TIMESTAMPTZ,
|
||||
properties JSONB
|
||||
)").execute(pool).await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS idx_tkg_op_file_uuid ON tkg_operation_log(file_uuid)")
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
// ── Functions & Triggers ──
|
||||
sqlx::query(
|
||||
"CREATE OR REPLACE FUNCTION update_search_vector() RETURNS TRIGGER AS $func$
|
||||
|
||||
Reference in New Issue
Block a user