-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
79 lines (68 loc) · 2.55 KB
/
database.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
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
68
69
70
71
72
73
74
75
76
77
78
79
-- Active: 1723868453146@@127.0.0.1@5432@management_perpustakaan
CREATE DATABASE management_perpustakaan;
CREATE TABLE public.customers (
id character varying(36) DEFAULT gen_random_uuid () NOT NULL PRIMARY KEY,
code character varying(255) NOT NULL,
name character varying(255) NOT NULL,
created_at timestamp(6) without time zone,
updated_at timestamp(6) without time zone,
deleted_at timestamp(6) without time zone
);
SELECT * FROM customers
CREATE TABLE public.users (
id character varying(36) DEFAULT gen_random_uuid () NOT NULL PRIMARY KEY,
email character varying(255) NOT NULL,
password character varying(255) NOT NULL
);
INSERT INTO
public.users (id, email, password)
VALUES (
'4246fb58-ff45-4d2a-8946-93e541fc39fd',
'admin@yogi.id',
'$2a$12$Rvslxj25D4OU7w3Ercz/IucMiDkEp1dOCSwq902oWpy0mqcUx2GAq'
);
CREATE TABLE public.book_stocks (
id SERIAL PRIMARY key,
book_id character varying(36) NOT NULL,
code character varying(50) NOT NULL,
status character varying(50) NOT NULL,
borrower_id character varying(36),
borrowed_at timestamp(6) without time zone
);
CREATE TABLE public.books (
id character varying(36) DEFAULT gen_random_uuid () NOT NULL PRIMARY KEY,
title character varying(255) NOT NULL,
description text,
isbn character varying(100) NOT NULL,
created_at timestamp(6) without time zone,
updated_at timestamp(6) without time zone,
deleted_at timestamp(6) without time zone,
-- cover_id character varying(36)
);
CREATE TABLE public.journals (
id character varying(36) DEFAULT gen_random_uuid () NOT NULL,
book_id character varying(36) NOT NULL,
stock_code character varying(255) NOT NULL,
customer_id character varying(36) NOT NULL,
status character varying(50) NOT NULL,
borrowed_at timestamp(6) without time zone NOT NULL,
returned_at timestamp(6) without time zone,
-- due_at timestamp(6) without time zone
);
CREATE TABLE public.media (
id character varying(36) DEFAULT gen_random_uuid () NOT NULL,
path text,
created_at timestamp(6) without time zone NOT NULL
);
ALTER TABLE books ADD COLUMN cover_id CHARACTER varying(100);
ALTER TABLE journals
ADD COLUMN due_at timestamp(6) without time zone;
CREATE TABLE public.charges (
id character varying(36) NOT NULL,
journal_id character varying(36) NOT NULL,
days_late integer DEFAULT 1 NOT NULL,
daily_late_fee integer NOT NULL,
total integer NOT NULL,
user_id character varying(36) NOT NULL,
created_at timestamp(6) without time zone
);