-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema-db.txt
67 lines (62 loc) · 1.86 KB
/
schema-db.txt
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
DROP TABLE IF EXISTS admin;
CREATE TABLE admin(
id BIGSERIAL PRIMARY KEY,
unique_id VARCHAR(50) UNIQUE,
name VARCHAR(200),
username VARCHAR(200),
password TEXT,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITHOUT TIME ZONE
);
DROP TABLE IF EXISTS users;
CREATE TABLE users(
id BIGSERIAL PRIMARY KEY,
unique_id VARCHAR(50) UNIQUE,
name VARCHAR(200),
username VARCHAR(200),
password TEXT,
admin_id VARCHAR(50),
type VARCHAR(100),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITHOUT TIME ZONE
);
DROP TABLE IF EXISTS books;
CREATE TABLE books(
id BIGSERIAL PRIMARY KEY,
code VARCHAR(200),
title VARCHAR(200),
author VARCHAR(200),
stock INT,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITHOUT TIME ZONE
);
DROP TABLE IF EXISTS books_request;
CREATE TABLE books_request(
id BIGSERIAL PRIMARY KEY,
user_id VARCHAR(50),
title VARCHAR(200),
author VARCHAR(200),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITHOUT TIME ZONE
);
DROP TABLE IF EXISTS books_issue;
CREATE TABLE books_issue(
id BIGSERIAL PRIMARY KEY,
book_id BIGINT,
user_id VARCHAR(50),
book_code VARCHAR(200),
title VARCHAR(200),
returned BOOLEAN DEFAULT false,
issue_date TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
return_date TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() + '7 day'::interval,
updated_at TIMESTAMP WITHOUT TIME ZONE
);
DROP TABLE IF EXISTS user_penalty;
CREATE TABLE user_penalty(
id BIGSERIAL PRIMARY KEY,
user_id VARCHAR(50),
status BOOLEAN DEFAULT true,
penalty_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
release_date TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() + '3 day'::interval,
updated_at TIMESTAMP WITHOUT TIME ZONE
);