nidus-sync/db/migrations/00147_communication.sql
Eli Ribble fcd95f1a25
Get back to compiling, but using new jet for publicreport
This was an epically long change, and a terrible idea, but it compiles.
This was essentially a cascade that came about because I can't blend jet
and bob in the same transaction. In for a penny, I guess...
2026-05-07 10:39:17 +00:00

44 lines
1.2 KiB
SQL

-- +goose Up
CREATE TYPE CommunicationStatus AS ENUM (
'closed',
'invalid',
'new',
'opened',
'pending',
'possible-issue',
'possible-resolved',
'resolved'
);
CREATE TABLE communication (
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
id SERIAL,
organization_id INTEGER NOT NULL REFERENCES organization(id),
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),
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),
PRIMARY KEY(id)
);
-- +goose Down
DROP TABLE communication;
DROP TABLE communication_log_entry;
DROP TYPE CommunicationLogEntry;