Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

refactor: Improve error handling and user feedback in file upload process for enhanced reliability and user experience

wizardchen60241a2d2993
diff --git a/migrations/versioned/000014_backfill_models_tenant_id.down.sql b/migrations/versioned/000014_backfill_models_tenant_id.down.sql
new file mode 100644
index 000000000..d7e6baebf
--- /dev/null
+++ b/migrations/versioned/000014_backfill_models_tenant_id.down.sql
@@ -0,0 +1,13 @@
+-- 14-backfill-models-tenant-id.down.sql
+-- Reset tenant_id in models back to 0 for records tied to knowledges entries
+
+BEGIN;
+
+UPDATE models m
+JOIN knowledges k ON m.id = k.id
+SET m.tenant_id = 0
+WHERE m.tenant_id = k.tenant_id;
+
+COMMIT;
+
+
diff --git a/migrations/versioned/000014_backfill_models_tenant_id.up.sql b/migrations/versioned/000014_backfill_models_tenant_id.up.sql
new file mode 100644
index 000000000..2f9a1d83f
--- /dev/null
+++ b/migrations/versioned/000014_backfill_models_tenant_id.up.sql
@@ -0,0 +1,20 @@
+-- 14-backfill-models-tenant-id.up.sql
+-- Backfill tenant_id in models table using knowledges records that share the same id
+
+BEGIN;
+
+WITH tenant_source AS (
+ SELECT
+ k.id AS model_id,
+ k.tenant_id
+ FROM knowledges k
+ WHERE k.tenant_id IS NOT NULL
+)
+UPDATE models m
+JOIN tenant_source ts ON m.id = ts.model_id
+SET m.tenant_id = ts.tenant_id
+WHERE m.tenant_id = 0;
+
+COMMIT;
+
+