From d21e6c1b2ddf2562be239682f50a57eac2686a1b Mon Sep 17 00:00:00 2001 From: hammadb Date: Fri, 13 Oct 2023 00:25:58 -0700 Subject: [PATCH] Add basic schema --- .../sysdb/00004-tenants-databases.sqlite.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 chromadb/migrations/sysdb/00004-tenants-databases.sqlite.sql diff --git a/chromadb/migrations/sysdb/00004-tenants-databases.sqlite.sql b/chromadb/migrations/sysdb/00004-tenants-databases.sqlite.sql new file mode 100644 index 000000000000..8caefdf9a217 --- /dev/null +++ b/chromadb/migrations/sysdb/00004-tenants-databases.sqlite.sql @@ -0,0 +1,19 @@ +CREATE TABLE tenants ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + UNIQUE (name) +); + +CREATE TABLE databases ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + tenant_id TEXT NOT NULL REFERENCES tenants(id) ON DELETE CASCADE, + UNIQUE (name) +); + +ALTER TABLE collections + ADD COLUMN database_id TEXT NOT NULL REFERENCES databases(id); -- ON DELETE CASCADE not supported by sqlite in ALTER TABLE + +-- Create default tenant and database +INSERT INTO tenants (id, name) VALUES ('default', 'default'); +INSERT INTO databases (id, name, tenant_id) VALUES ('default', 'default', 'default');