Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit b3e10de

Browse files
author
bitfl0wer
committed
feat: create new actors tabl;e, rename old table to local_actors
1 parent 8f2903f commit b3e10de

13 files changed

+96
-42
lines changed

.sqlx/query-24a05d1bf9ab87e03612173d26eabaaa6ac2562988ea31fb26a35886ed30bdb5.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-36d50832e62147d09cdfea411aa263cc023287ea6aeea9f9f23cd3b956bbd0ae.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.sqlx/query-38d45f427e861ba8929b77afe1778aef529b48dd866d2b26141ded6ff9293c53.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-62cd20bf7cf1e63b667a93da8a6c1aef1a4e07fe12365f3741e435a7c15dace7.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.sqlx/query-695a7da31f8830cc882d0fd029c59a14c1d2aaf7556c32a56b70d76a327c5235.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-8abc13241dafdf0d0ab048685a7d8533b799f7edba6ce2735d762fe0c24f3a29.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/tokens_base_fixture.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ INSERT INTO algorithm_identifiers (id, algorithm_identifier, common_name, parame
77
(2, 'id-ecPublicKey', 'EC', NULL);
88

99
-- Test actors (users 1-4 to support various test scenarios)
10-
INSERT INTO actors (uaid, local_name, deactivated, joined) VALUES
10+
-- First insert into actors table with type 'local'
11+
INSERT INTO actors (uaid, type) VALUES
12+
('00000000-0000-0000-0000-000000000001', 'local'),
13+
('00000000-0000-0000-0000-000000000002', 'local'),
14+
('00000000-0000-0000-0000-000000000003', 'local'),
15+
('00000000-0000-0000-0000-000000000004', 'local');
16+
17+
-- Then insert into local_actors with the specific local actor data
18+
INSERT INTO local_actors (uaid, local_name, deactivated, joined) VALUES
1119
('00000000-0000-0000-0000-000000000001', 'test_user_1', FALSE, NOW()),
1220
('00000000-0000-0000-0000-000000000002', 'test_user_2', FALSE, NOW()),
1321
('00000000-0000-0000-0000-000000000003', 'test_user_3', FALSE, NOW()),

migrations/0000_actors.sql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
-- TODO: does this apply for foreign actors also?
1+
CREATE TYPE actor_type AS ENUM ('local', 'foreign');
2+
23
CREATE TABLE IF NOT EXISTS actors (
3-
-- unique actor id
44
uaid UUID PRIMARY KEY DEFAULT gen_random_uuid(),
5+
type ACTOR_TYPE NOT NULL
6+
);
7+
8+
CREATE TABLE IF NOT EXISTS local_actors (
9+
-- unique actor id
10+
uaid UUID PRIMARY KEY REFERENCES actors (uaid),
511
local_name TEXT UNIQUE NOT NULL,
612
deactivated BOOLEAN NOT NULL DEFAULT false,
713
joined TIMESTAMP NOT NULL DEFAULT now()
814
);
915

10-
COMMENT ON TABLE actors IS 'Actors from this home server.';
16+
COMMENT ON TABLE local_actors IS 'Actors from this home server.';
1117

1218
CREATE TABLE IF NOT EXISTS name_history (
13-
uaid UUID NOT NULL REFERENCES actors (uaid) ON DELETE CASCADE,
19+
uaid UUID NOT NULL REFERENCES local_actors (uaid) ON DELETE CASCADE,
1420
time TIMESTAMP NOT NULL DEFAULT now(),
1521
local_name_old TEXT NOT NULL,
1622
local_name_new TEXT NOT NULL,

migrations/0001_federated_identity.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COMMENT ON TABLE algorithm_identifiers IS 'PKCS #10 Algorithm Identifiers for si
99

1010
CREATE TABLE IF NOT EXISTS public_keys (
1111
id BIGSERIAL PRIMARY KEY,
12-
uaid UUID NOT NULL REFERENCES actors (uaid),
12+
uaid UUID NOT NULL REFERENCES local_actors (uaid),
1313
pubkey TEXT UNIQUE NOT NULL,
1414
UNIQUE (uaid, pubkey),
1515
algorithm_identifier INT NOT NULL REFERENCES algorithm_identifiers (id) ON DELETE CASCADE
@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS public_keys (
1818
COMMENT ON TABLE public_keys IS 'Public keys of both actors, cached actors and home servers, including this home server.';
1919

2020
CREATE TABLE IF NOT EXISTS subjects (
21-
uaid UUID PRIMARY KEY REFERENCES actors (uaid),
21+
uaid UUID PRIMARY KEY REFERENCES local_actors (uaid),
2222
domain_components TEXT [] NOT NULL,
2323
pem_encoded TEXT UNIQUE NOT NULL
2424
);
@@ -36,7 +36,7 @@ COMMENT ON TABLE issuers IS 'Issuers. Deduplicates issuer entries. Especially he
3636
CREATE TABLE IF NOT EXISTS idcsr (
3737
id BIGSERIAL PRIMARY KEY,
3838
serial_number NUMERIC(49, 0) UNIQUE NOT NULL,
39-
uaid UUID NOT NULL REFERENCES actors (uaid) ON DELETE CASCADE,
39+
uaid UUID NOT NULL REFERENCES local_actors (uaid) ON DELETE CASCADE,
4040
actor_public_key_id BIGINT UNIQUE NOT NULL REFERENCES public_keys (id) ON DELETE CASCADE,
4141
actor_signature TEXT UNIQUE NOT NULL,
4242
session_id VARCHAR(32) NOT NULL,

migrations/0004_services.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ CREATE TYPE service AS (
66

77
CREATE TABLE IF NOT EXISTS actor_service_mapping (
88
id BIGSERIAL PRIMARY KEY,
9-
uaid UUID UNIQUE REFERENCES actors (uaid) ON DELETE CASCADE,
9+
uaid UUID UNIQUE REFERENCES local_actors (uaid) ON DELETE CASCADE,
1010
services SERVICE [] NULL
1111
);

0 commit comments

Comments
 (0)