forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sql
35 lines (31 loc) · 801 Bytes
/
script.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
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
CREATE UNLOGGED TABLE client (
"id" uuid DEFAULT gen_random_uuid(),
"client_id" SERIAL PRIMARY KEY,
"amount" INTEGER NOT NULL,
"limit" INTEGER NOT NULL
);
CREATE UNLOGGED TABLE transaction (
"id" uuid DEFAULT gen_random_uuid(),
"transaction_id" SERIAL PRIMARY KEY,
"value" INTEGER NOT NULL,
"type" CHAR(1) NOT NULL,
"description" VARCHAR(10) NOT NULL,
"client_id" INTEGER NOT NULL,
"created_at" TIMESTAMP NOT NULL DEFAULT NOW(),
CONSTRAINT "fk_client_transaction_id"
FOREIGN KEY (client_id) REFERENCES client(client_id)
);
DO $$
BEGIN
INSERT INTO client ("amount", "limit")
VALUES
(0, 1000 * 100),
(0, 800 * 100),
(0, 10000 * 100),
(0, 100000 * 100),
(0, 5000 * 100);
END;
$$;