-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
28 lines (24 loc) · 926 Bytes
/
Copy pathinit.sql
File metadata and controls
28 lines (24 loc) · 926 Bytes
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
CREATE TABLE processed_transactions
(
transaction_id VARCHAR(100) PRIMARY KEY,
merchant_id VARCHAR(100) NOT NULL,
amount NUMERIC(38, 2) NOT NULL,
currency CHAR(3) NOT NULL,
status VARCHAR(20) NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
processed_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE merchant_aggregates
(
merchant_id VARCHAR(100) NOT NULL,
currency CHAR(3) NOT NULL,
successful_transaction_count BIGINT NOT NULL,
successful_transaction_amount NUMERIC(38, 2) NOT NULL,
updated_at TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_merchant_aggregates
PRIMARY KEY (merchant_id, currency),
CONSTRAINT ck_successful_count_non_negative
CHECK (successful_transaction_count >= 0),
CONSTRAINT ck_successful_amount_non_negative
CHECK (successful_transaction_amount >= 0)
);