Added original migrations
This commit is contained in:
parent
5947ddb91c
commit
1569aaa760
3 changed files with 48 additions and 0 deletions
3
migrations/2022-01-02-195433_users-and-jwt/down.sql
Normal file
3
migrations/2022-01-02-195433_users-and-jwt/down.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
drop table refresh_tokens cascade;
|
||||
drop table users cascade;
|
||||
20
migrations/2022-01-02-195433_users-and-jwt/up.sql
Normal file
20
migrations/2022-01-02-195433_users-and-jwt/up.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
);
|
||||
|
||||
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