Skip to content

Commit 224ae91

Browse files
committed
remove keys from accounts table
1 parent 70943b9 commit 224ae91

File tree

1 file changed

+19
-22
lines changed
  • crates/kitsune-db/migrations/2023-12-16-192941_initial

1 file changed

+19
-22
lines changed

crates/kitsune-db/migrations/2023-12-16-192941_initial/up.sql

+19-22
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,26 @@ $$
3535

3636
CREATE TABLE accounts
3737
(
38-
id UUID PRIMARY KEY,
39-
display_name TEXT,
40-
note TEXT,
38+
id UUID PRIMARY KEY,
39+
display_name TEXT,
40+
note TEXT,
4141

4242
-- Use special collation to ignore case and accent differences
43-
username TEXT NOT NULL COLLATE kitsune.ignore_accent_case,
44-
locked BOOLEAN NOT NULL,
45-
local BOOLEAN NOT NULL,
46-
domain TEXT NOT NULL,
47-
account_type INTEGER NOT NULL,
48-
url TEXT UNIQUE NOT NULL,
49-
50-
public_key_id TEXT NOT NULL UNIQUE,
51-
public_key TEXT NOT NULL,
43+
username TEXT NOT NULL COLLATE kitsune.ignore_accent_case,
44+
locked BOOLEAN NOT NULL,
45+
local BOOLEAN NOT NULL,
46+
domain TEXT NOT NULL,
47+
account_type INTEGER NOT NULL,
48+
url TEXT UNIQUE NOT NULL,
5249

53-
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
54-
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
50+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
51+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
5552

5653
-- Generated full-text search column
57-
account_ts TSVECTOR GENERATED ALWAYS AS (
58-
setweight(to_tsvector('simple', COALESCE(display_name, '')) ||
59-
to_tsvector('simple', username), 'A') ||
60-
setweight(to_tsvector('simple', COALESCE(note, '')), 'B')) STORED NOT NULL
54+
account_ts TSVECTOR GENERATED ALWAYS AS (
55+
setweight(to_tsvector('simple', COALESCE(display_name, '')) ||
56+
to_tsvector('simple', username), 'A') ||
57+
setweight(to_tsvector('simple', COALESCE(note, '')), 'B')) STORED NOT NULL
6158
);
6259

6360
-- Unique constraints
@@ -69,9 +66,10 @@ CREATE INDEX "idx-accounts-account_ts" ON accounts USING GIN (account_ts);
6966

7067
CREATE TABLE cryptographic_keys
7168
(
72-
key_id TEXT PRIMARY KEY,
73-
key_pem TEXT NOT NULL,
74-
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
69+
key_id TEXT PRIMARY KEY,
70+
public_key_pem TEXT NOT NULL,
71+
private_key_pem TEXT,
72+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
7573
);
7674

7775
CREATE TABLE accounts_cryptographic_keys
@@ -171,7 +169,6 @@ CREATE TABLE users
171169
email TEXT NOT NULL UNIQUE,
172170
password TEXT UNIQUE,
173171
domain TEXT NOT NULL,
174-
private_key TEXT NOT NULL,
175172

176173
-- Email confirmation
177174
confirmed_at TIMESTAMPTZ,

0 commit comments

Comments
 (0)