From bbdf38018b47328b5faa2cef635c37095045be72 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 12 Jun 2026 01:54:21 +0200 Subject: feat(server): Really make users stateless (with tests) This commit also remove another load of unneeded features. --- .../db/server-pg-migrations/20230623070418_records.sql | 2 +- .../db/server-pg-migrations/20240614104159_idx-cache.sql | 12 ++++++------ .../20260611222503_make_user-id_an_uuid.sql | 11 +++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 crates/turtle/db/server-pg-migrations/20260611222503_make_user-id_an_uuid.sql (limited to 'crates/turtle/db/server-pg-migrations') diff --git a/crates/turtle/db/server-pg-migrations/20230623070418_records.sql b/crates/turtle/db/server-pg-migrations/20230623070418_records.sql index 22437595..a3e5de2e 100644 --- a/crates/turtle/db/server-pg-migrations/20230623070418_records.sql +++ b/crates/turtle/db/server-pg-migrations/20230623070418_records.sql @@ -8,7 +8,7 @@ create table records ( version text not null, tag text not null, -- what is this? history, kv, whatever. Remember clients get a log per tag per host data text not null, -- store the actual history data, encrypted. I don't wanna know! - cek text not null, + cek text not null, user_id bigint not null, -- allow multiple users created_at timestamp not null default current_timestamp diff --git a/crates/turtle/db/server-pg-migrations/20240614104159_idx-cache.sql b/crates/turtle/db/server-pg-migrations/20240614104159_idx-cache.sql index 76425ed7..12bbbecc 100644 --- a/crates/turtle/db/server-pg-migrations/20240614104159_idx-cache.sql +++ b/crates/turtle/db/server-pg-migrations/20240614104159_idx-cache.sql @@ -1,8 +1,8 @@ -create table store_idx_cache( - id bigserial primary key, - user_id bigint, +CREATE TABLE store_idx_cache( + id BIGSERIAL PRIMARY KEY, + user_id UUID, - host uuid, - tag text, - idx bigint + host UUID, + tag TEXT, + idx BIGINT ); diff --git a/crates/turtle/db/server-pg-migrations/20260611222503_make_user-id_an_uuid.sql b/crates/turtle/db/server-pg-migrations/20260611222503_make_user-id_an_uuid.sql new file mode 100644 index 00000000..d31c23e2 --- /dev/null +++ b/crates/turtle/db/server-pg-migrations/20260611222503_make_user-id_an_uuid.sql @@ -0,0 +1,11 @@ +-- Add migration script here + +ALTER TABLE records +DROP COLUMN IF EXISTS user_id; +ALTER TABLE records +ADD COLUMN user_id UUID NOT NULL; + +ALTER TABLE store +DROP COLUMN IF EXISTS user_id; +ALTER TABLE store +ADD COLUMN user_id UUID NOT NULL; -- cgit v1.3.1