-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathschema-postgresql.sql
33 lines (29 loc) · 1.59 KB
/
schema-postgresql.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
CREATE TABLE IF NOT EXISTS DEAD_LETTER_CHANNEL (
id BIGSERIAL PRIMARY KEY,
payload VARCHAR NOT NULL,
data_set_code VARCHAR,
report_period_offset INTEGER NOT NULL,
organisation_unit_id VARCHAR,
error_message VARCHAR NOT NULL,
status VARCHAR NOT NULL CHECK (status = 'PROCESSED' OR status = 'RETRY' OR status = 'ERROR'),
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_processed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX ON DEAD_LETTER_CHANNEL(status);
CREATE TABLE IF NOT EXISTS POLLER (
flow_uuid VARCHAR PRIMARY KEY,
last_run_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS TOKEN (
value_ VARCHAR PRIMARY KEY
);
CREATE TABLE IF NOT EXISTS SUCCESS_LOG (
id BIGSERIAL PRIMARY KEY,
dhis_request VARCHAR NOT NULL,
dhis_response VARCHAR NOT NULL,
rapidpro_payload VARCHAR NOT NULL,
data_set_code VARCHAR NOT NULL,
report_period_offset INTEGER NOT NULL,
organisation_unit_id VARCHAR,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);