This repository has been archived on 2021-10-25. You can view files and clone it, but cannot push or open issues/pull-requests.
2021-08-20 14:06:01 +02:00
|
|
|
CREATE TABLE users (
|
|
|
|
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
|
|
|
|
|
|
username varchar(32) UNIQUE NOT NULL,
|
2021-08-20 14:46:19 +02:00
|
|
|
-- Hashed + salted representation of the username
|
|
|
|
password text NOT NULL,
|
|
|
|
-- Wether the user is currently blocked
|
2021-08-20 22:25:21 +02:00
|
|
|
blocked boolean NOT NULL DEFAULT false,
|
|
|
|
-- Wether the user is an admin
|
|
|
|
admin boolean NOT NULL DEFAULT false
|
2021-08-20 16:52:58 +02:00
|
|
|
);
|
2021-08-20 14:46:19 +02:00
|
|
|
|
|
|
|
-- Stores refresh tokens
|
|
|
|
CREATE TABLE refresh_tokens (
|
|
|
|
-- This is more efficient than storing the text
|
|
|
|
token bytea PRIMARY KEY,
|
|
|
|
-- The user for whom the token was created
|
2021-08-22 10:42:58 +02:00
|
|
|
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
2021-08-20 14:46:19 +02:00
|
|
|
-- When the token expires
|
|
|
|
expires_at timestamp NOT NULL,
|
|
|
|
-- When the token was last used (is NULL until used)
|
|
|
|
last_used_at timestamp
|
|
|
|
);
|