-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathinit.sql
34 lines (26 loc) · 830 Bytes
/
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
32
33
CREATE TABLE IF NOT EXISTS clients (
"id" SERIAL,
"name" VARCHAR(50) NOT NULL,
"limit" INT NOT NULL,
"balance" INT DEFAULT 0,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS transactions (
"id" SERIAL,
"value" INT NOT NULL,
"type" VARCHAR(1) NOT NULL,
"description" VARCHAR(10) NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"client_id" INT NOT NULL,
CONSTRAINT "clients_fk" FOREIGN KEY ("client_id") REFERENCES clients("id")
);
DO $$
BEGIN
INSERT INTO clients ("name", "limit")
VALUES
('o barato sai caro', 1000 * 100),
('zan corp ltda', 800 * 100),
('les cruders', 10000 * 100),
('padaria joia de cocaia', 100000 * 100),
('kid mais', 5000 * 100);
END; $$