Skip to content

Commit c94b7f9

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

Some content is hidden

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

42 files changed

+4961
-132
lines changed
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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
created_at timestamptz NOT NULL default now(),
24+
updated_at timestamptz NOT NULL default now()
25+
);
26+
27+
ALTER TABLE storage.buckets_vectors ENABLE ROW LEVEL SECURITY;
28+
ALTER TABLE storage.vector_indexes ENABLE ROW LEVEL SECURITY;
29+
30+
EXECUTE 'GRANT SELECT ON TABLE storage.buckets_vectors TO ' || service_role || ', ' || authenticated_role || ', ' || anon_role;
31+
EXECUTE 'GRANT SELECT ON TABLE storage.vector_indexes TO ' || service_role || ', ' || authenticated_role || ', ' || anon_role;
32+
33+
CREATE UNIQUE INDEX IF NOT EXISTS vector_indexes_name_bucket_id_idx ON storage.vector_indexes (name, bucket_id);
34+
END$$;

0 commit comments

Comments
 (0)