-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathscript.sql
14 lines (13 loc) · 821 Bytes
/
script.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
CREATE TABLE IF NOT EXISTS accounts(
id INTEGER NOT NULL,
credit_limit BIGINT NOT NULL,
balance BIGINT NOT NULL,
last_transactions JSON[] NOT NULL,
CONSTRAINT pk_balance PRIMARY KEY(id),
CONSTRAINT check_balance_limit CHECK (credit_limit + balance >= 0)
);
INSERT INTO accounts(id, credit_limit, balance, last_transactions) VALUES(1, 100000, 0, ARRAY[]::JSON[]);
INSERT INTO accounts(id, credit_limit, balance, last_transactions) VALUES(2, 80000, 0, ARRAY[]::JSON[]);
INSERT INTO accounts(id, credit_limit, balance, last_transactions) VALUES(3, 1000000, 0, ARRAY[]::JSON[]);
INSERT INTO accounts(id, credit_limit, balance, last_transactions) VALUES(4, 10000000, 0, ARRAY[]::JSON[]);
INSERT INTO accounts(id, credit_limit, balance, last_transactions) VALUES(5, 500000, 0, ARRAY[]::JSON[]);