chore: 添加虚拟环境到仓库

- 添加 backend_service/venv 虚拟环境
- 包含所有Python依赖包
- 注意:虚拟环境约393MB,包含12655个文件
This commit is contained in:
2025-12-03 10:19:25 +08:00
parent a6c2027caa
commit c4f851d387
12655 changed files with 3009376 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
CREATE TABLE collections (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
topic TEXT NOT NULL,
UNIQUE (name)
);
CREATE TABLE collection_metadata (
collection_id TEXT REFERENCES collections(id) ON DELETE CASCADE,
key TEXT NOT NULL,
str_value TEXT,
int_value INTEGER,
float_value REAL,
PRIMARY KEY (collection_id, key)
);

View File

@@ -0,0 +1,16 @@
CREATE TABLE segments (
id TEXT PRIMARY KEY,
type TEXT NOT NULL,
scope TEXT NOT NULL,
topic TEXT,
collection TEXT REFERENCES collection(id)
);
CREATE TABLE segment_metadata (
segment_id TEXT REFERENCES segments(id) ON DELETE CASCADE,
key TEXT NOT NULL,
str_value TEXT,
int_value INTEGER,
float_value REAL,
PRIMARY KEY (segment_id, key)
);

View File

@@ -0,0 +1 @@
ALTER TABLE collections ADD COLUMN dimension INTEGER;

View File

@@ -0,0 +1,29 @@
CREATE TABLE IF NOT EXISTS tenants (
id TEXT PRIMARY KEY,
UNIQUE (id)
);
CREATE TABLE IF NOT EXISTS databases (
id TEXT PRIMARY KEY, -- unique globally
name TEXT NOT NULL, -- unique per tenant
tenant_id TEXT NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
UNIQUE (tenant_id, name) -- Ensure that a tenant has only one database with a given name
);
CREATE TABLE IF NOT EXISTS collections_tmp (
id TEXT PRIMARY KEY, -- unique globally
name TEXT NOT NULL, -- unique per database
topic TEXT NOT NULL,
dimension INTEGER,
database_id TEXT NOT NULL REFERENCES databases(id) ON DELETE CASCADE,
UNIQUE (name, database_id)
);
-- Create default tenant and database
INSERT OR REPLACE INTO tenants (id) VALUES ('default_tenant'); -- The default tenant id is 'default_tenant' others are UUIDs
INSERT OR REPLACE INTO databases (id, name, tenant_id) VALUES ('00000000-0000-0000-0000-000000000000', 'default_database', 'default_tenant');
INSERT OR REPLACE INTO collections_tmp (id, name, topic, dimension, database_id)
SELECT id, name, topic, dimension, '00000000-0000-0000-0000-000000000000' FROM collections;
DROP TABLE collections;
ALTER TABLE collections_tmp RENAME TO collections;

View File

@@ -0,0 +1,4 @@
-- Remove the topic column from the Collections and Segments tables
ALTER TABLE collections DROP COLUMN topic;
ALTER TABLE segments DROP COLUMN topic;

View File

@@ -0,0 +1,6 @@
-- SQLite does not support adding check with alter table, as a result, adding a check
-- involve creating a new table and copying the data over. It is over kill with adding
-- a boolean type column. The application write to the table needs to ensure the data
-- integrity.
ALTER TABLE collection_metadata ADD COLUMN bool_value INTEGER;
ALTER TABLE segment_metadata ADD COLUMN bool_value INTEGER;

View File

@@ -0,0 +1,2 @@
-- Stores collection configuration dictionaries.
ALTER TABLE collections ADD COLUMN config_json_str TEXT;

View File

@@ -0,0 +1,7 @@
-- Records when database maintenance operations are performed.
-- At time of creation, this table is only used to record vacuum operations.
CREATE TABLE maintenance_log (
id INT PRIMARY KEY,
timestamp INT NOT NULL,
operation TEXT NOT NULL
);

View File

@@ -0,0 +1,11 @@
-- This makes segments.collection non-nullable.
CREATE TABLE segments_temp (
id TEXT PRIMARY KEY,
type TEXT NOT NULL,
scope TEXT NOT NULL,
collection TEXT REFERENCES collection(id) NOT NULL
);
INSERT INTO segments_temp SELECT * FROM segments;
DROP TABLE segments;
ALTER TABLE segments_temp RENAME TO segments;