forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.sql
43 lines (37 loc) · 1.13 KB
/
db.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
36
37
38
39
40
41
42
43
CREATE TABLE clients (
id SERIAL PRIMARY KEY,
saldo INTEGER NOT NULL DEFAULT 0,
limite INTEGER NOT NULL
);
INSERT INTO clients (id, limite)
VALUES (1, 100000),
(2, 80000),
(3, 1000000),
(4, 10000000),
(5, 500000);
CREATE TABLE event_journal (
ordering BIGSERIAL NOT NULL PRIMARY KEY,
persistence_id VARCHAR(255) NOT NULL,
sequence_nr BIGINT NOT NULL,
is_deleted BOOLEAN NOT NULL,
created_at BIGINT NOT NULL,
manifest VARCHAR(500) NOT NULL,
payload BYTEA NOT NULL,
tags VARCHAR(100) NULL,
serializer_id INTEGER NULL,
CONSTRAINT event_journal_uq UNIQUE (persistence_id, sequence_nr)
);
CREATE TABLE snapshot_store (
persistence_id VARCHAR(255) NOT NULL,
sequence_nr BIGINT NOT NULL,
created_at BIGINT NOT NULL,
manifest VARCHAR(500) NOT NULL,
payload BYTEA NOT NULL,
serializer_id INTEGER NULL,
CONSTRAINT snapshot_store_pk PRIMARY KEY (persistence_id, sequence_nr)
);
CREATE TABLE metadata (
persistence_id VARCHAR(255) NOT NULL,
sequence_nr BIGINT NOT NULL,
CONSTRAINT metadata_pk PRIMARY KEY (persistence_id, sequence_nr)
);