-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathinit.sql
29 lines (27 loc) · 975 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
CREATE UNLOGGED TABLE "customers" (
"id" SERIAL NOT NULL PRIMARY KEY,
"name" VARCHAR(100) NOT NULL,
"credit" INTEGER NOT NULL,
"balance" BIGINT NOT NULL DEFAULT 0
);
CREATE UNLOGGED TABLE "transactions" (
"id" SERIAL NOT NULL PRIMARY KEY,
"customer_id" INTEGER NOT NULL,
"type" CHARACTER(1) NOT NULL,
"amount" BIGINT NOT NULL,
"description" VARCHAR(10) NOT NULL,
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "fk_clientes_transacoes_id"
FOREIGN KEY ("customer_id") REFERENCES customers ("id")
);
DO
$$
BEGIN
INSERT INTO customers (name, credit, balance)
VALUES ('mark zuguenbuerguerr', 1000 * 100, 0),
('arnold schuzenega', 800 * 100, 0),
('bill gata', 10000 * 100, 0),
('ellon mockito', 100000 * 100, 0),
('jack mau', 5000 * 100, 0);
END;
$$;