-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
31 lines (27 loc) · 1.14 KB
/
init.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(64) NOT NULL UNIQUE,
password VARCHAR(64) NOT NULL,
deleted_at TIMESTAMPTZ DEFAULT NULL,
token TEXT DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS tasks (
id SERIAL PRIMARY KEY,
priority VARCHAR(4) DEFAULT NULL,
title VARCHAR(255) NOT NULL,
completed_at TIMESTAMPTZ DEFAULT NULL,
description TEXT DEFAULT NULL,
deleted_at TIMESTAMPTZ DEFAULT NULL,
user_id INTEGER DEFAULT NULL,
is_default BOOLEAN DEFAULT FALSE,
CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(id)
);
INSERT INTO users (username, password) VALUES ('deleteduser', '$2b$12$x3hs5oMgjHdcV1GUEElfsO19JtS6.ixJAX9Cj62GyhpdPAIW25sky');
INSERT INTO tasks (title, deleted_at, user_id) VALUES (
'my deleted task',
NOW(),
(select id from users where username = 'deleteduser')
);
INSERT INTO tasks (priority, title, description, is_default) VALUES
('A', 'I am a task, you can complete me by checking the box', 'This is my description', true),
('B', 'See my details for by clicking me', 'My description can be changed', true);