Layed groundwork for microservice split
This commit is contained in:
parent
e2003442e2
commit
0b048eb8b0
44 changed files with 461 additions and 259 deletions
|
|
@ -0,0 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE IF EXISTS users, refresh_tokens CASCADE;
|
||||
23
blog/migrations/2021-08-20-110251_users-and-auth/up.sql
Normal file
23
blog/migrations/2021-08-20-110251_users-and-auth/up.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
CREATE TABLE users (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
|
||||
username varchar(32) UNIQUE NOT NULL,
|
||||
-- Hashed + salted representation of the username
|
||||
password text NOT NULL,
|
||||
-- Wether the user is currently blocked
|
||||
blocked boolean NOT NULL DEFAULT false,
|
||||
-- Wether the user is an admin
|
||||
admin boolean NOT NULL DEFAULT false
|
||||
);
|
||||
|
||||
-- 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
|
||||
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
-- When the token expires
|
||||
expires_at timestamp NOT NULL,
|
||||
-- When the token was last used (is NULL until used)
|
||||
last_used_at timestamp
|
||||
);
|
||||
Reference in a new issue