Skip to content

Commit 01797cc

Browse files
committed
feat: vector buckets
1 parent 4155c4c commit 01797cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+6840
-141
lines changed

.env.test.sample

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ AWS_DEFAULT_REGION=ap-southeast-1
2222
STORAGE_S3_ENDPOINT=http://127.0.0.1:9000
2323
STORAGE_S3_PROTOCOL=http
2424
STORAGE_S3_FORCE_PATH_STYLE=true
25-
REQUEST_X_FORWARDED_HOST_REGEXP=
25+
REQUEST_X_FORWARDED_HOST_REGEXP=
26+
27+
VECTOR_ENABLED=true
28+
ICEBERG_ENABLED=true

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ jobs:
8282
MULTI_TENANT: false
8383
S3_PROTOCOL_ACCESS_KEY_ID: ${{ secrets.TENANT_ID }}
8484
S3_PROTOCOL_ACCESS_KEY_SECRET: ${{ secrets.SERVICE_KEY }}
85+
VECTOR_ENABLED: true
86+
ICEBERG_ENABLED: true
8587

8688
- name: Upload coverage results to Coveralls
8789
uses: coverallsapp/github-action@master
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE tenants ADD COLUMN IF NOT EXISTS feature_vector_buckets boolean NOT NULL DEFAULT false;
2+
ALTER TABLE tenants ADD COLUMN IF NOT EXISTS feature_vector_buckets_max_buckets int NOT NULL DEFAULT 10;
3+
ALTER TABLE tenants ADD COLUMN IF NOT EXISTS feature_vector_buckets_max_indexes int NOT NULL DEFAULT 5;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DO $$
2+
DECLARE
3+
BEGIN
4+
IF NOT EXISTS (
5+
SELECT 1
6+
FROM pg_enum
7+
JOIN pg_type ON pg_enum.enumtypid = pg_type.oid
8+
WHERE pg_type.typname = 'buckettype'
9+
AND enumlabel = 'VECTOR'
10+
) THEN
11+
ALTER TYPE storage.BucketType ADD VALUE 'VECTOR';
12+
END IF;
13+
END$$;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
DO $$
2+
DECLARE
3+
anon_role text = COALESCE(current_setting('storage.anon_role', true), 'anon');
4+
authenticated_role text = COALESCE(current_setting('storage.authenticated_role', true), 'authenticated');
5+
service_role text = COALESCE(current_setting('storage.service_role', true), 'service_role');
6+
BEGIN
7+
CREATE TABLE IF NOT EXISTS storage.buckets_vectors (
8+
id text not null primary key,
9+
type storage.BucketType NOT NULL default 'VECTOR',
10+
created_at timestamptz NOT NULL default now(),
11+
updated_at timestamptz NOT NULL default now()
12+
);
13+
14+
CREATE TABLE IF NOT EXISTS storage.vector_indexes
15+
(
16+
id text primary key default gen_random_uuid(),
17+
name text COLLATE "C" NOT NULL,
18+
bucket_id text NOT NULL references storage.buckets_vectors (id),
19+
data_type text NOT NULL,
20+
dimension integer NOT NULL,
21+
distance_metric text NOT NULL,
22+
metadata_configuration jsonb NULL,
23+
status text NOT NULL default 'PENDING',
24+
created_at timestamptz NOT NULL default now(),
25+
updated_at timestamptz NOT NULL default now()
26+
);
27+
28+
ALTER TABLE storage.buckets_vectors ENABLE ROW LEVEL SECURITY;
29+
ALTER TABLE storage.vector_indexes ENABLE ROW LEVEL SECURITY;
30+
31+
EXECUTE 'GRANT SELECT ON TABLE storage.buckets_vectors TO ' || service_role || ', ' || authenticated_role || ', ' || anon_role;
32+
EXECUTE 'GRANT SELECT ON TABLE storage.vector_indexes TO ' || service_role || ', ' || authenticated_role || ', ' || anon_role;
33+
34+
CREATE UNIQUE INDEX IF NOT EXISTS vector_indexes_name_bucket_id_idx ON storage.vector_indexes (name, bucket_id);
35+
END$$;

0 commit comments

Comments
 (0)