Skip to content

Commit

Permalink
Add basic schema
Browse files Browse the repository at this point in the history
  • Loading branch information
HammadB committed Oct 13, 2023
1 parent 47c73e9 commit d21e6c1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions chromadb/migrations/sysdb/00004-tenants-databases.sqlite.sql
Original file line number Diff line number Diff line change
@@ -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');

0 comments on commit d21e6c1

Please sign in to comment.