forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sql
24 lines (21 loc) · 829 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
CREATE TABLE IF NOT EXISTS account
(
id SERIAL PRIMARY KEY,
max_limit INT NOT NULL,
balance INT NOT NULL
);
CREATE TABLE IF NOT EXISTS transactions
(
id SERIAL PRIMARY KEY,
id_account INTEGER NOT NULL REFERENCES account,
amount INT NOT NULL,
kind VARCHAR(1) NOT NULL,
description VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_account_transaction_created_at ON transactions (created_at);
INSERT INTO account (max_limit, balance) VALUES (100000, 0);
INSERT INTO account (max_limit, balance) VALUES (80000, 0);
INSERT INTO account (max_limit, balance) VALUES (1000000, 0);
INSERT INTO account (max_limit, balance) VALUES (10000000, 0);
INSERT INTO account (max_limit, balance) VALUES (500000, 0);