2026-05-01 15:13:05 +00:00
|
|
|
-- +goose Up
|
2026-05-07 10:39:17 +00:00
|
|
|
CREATE TYPE CommunicationStatus AS ENUM (
|
|
|
|
|
'closed',
|
|
|
|
|
'invalid',
|
|
|
|
|
'new',
|
|
|
|
|
'opened',
|
|
|
|
|
'pending',
|
|
|
|
|
'possible-issue',
|
|
|
|
|
'possible-resolved',
|
|
|
|
|
'resolved'
|
|
|
|
|
);
|
2026-05-01 15:13:05 +00:00
|
|
|
CREATE TABLE communication (
|
|
|
|
|
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
|
|
|
|
id SERIAL,
|
2026-05-01 20:49:37 +00:00
|
|
|
organization_id INTEGER NOT NULL REFERENCES organization(id),
|
2026-05-01 15:13:05 +00:00
|
|
|
response_email_log_id INTEGER REFERENCES comms.email_log(id),
|
|
|
|
|
response_text_log_id INTEGER REFERENCES comms.text_log(id),
|
|
|
|
|
source_email_log_id INTEGER REFERENCES comms.email_log(id),
|
|
|
|
|
source_report_id INTEGER REFERENCES publicreport.report(id),
|
|
|
|
|
source_text_log_id INTEGER REFERENCES comms.text_log(id),
|
2026-05-07 10:39:17 +00:00
|
|
|
status CommunicationStatus NOT NULL,
|
|
|
|
|
PRIMARY KEY(id)
|
|
|
|
|
);
|
|
|
|
|
CREATE TYPE CommunicationLogEntry AS ENUM (
|
|
|
|
|
'created',
|
|
|
|
|
'status.closed',
|
|
|
|
|
'status.invalidated',
|
|
|
|
|
'status.opened',
|
|
|
|
|
'status.pending',
|
|
|
|
|
'status.possible-issue',
|
|
|
|
|
'status.possible-resolved'
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE communication_log_entry (
|
|
|
|
|
communication_id INTEGER NOT NULL REFERENCES communication(id),
|
|
|
|
|
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
|
|
|
|
id SERIAL,
|
|
|
|
|
type_ CommunicationLogEntry NOT NULL,
|
|
|
|
|
user_ INTEGER REFERENCES user_(id),
|
2026-05-01 15:13:05 +00:00
|
|
|
PRIMARY KEY(id)
|
|
|
|
|
);
|
|
|
|
|
-- +goose Down
|
|
|
|
|
DROP TABLE communication;
|
2026-05-07 10:39:17 +00:00
|
|
|
DROP TABLE communication_log_entry;
|
|
|
|
|
DROP TYPE CommunicationLogEntry;
|