nidus-sync/db/migrations/00114_publicreport_report_log.sql
Eli Ribble 1d2570c912
Add DB model for publicreport logs
It's just way easier to track that deriving the data every time an API
request is made.
2026-03-18 17:32:06 +00:00

39 lines
824 B
SQL

-- +goose UP
CREATE TYPE publicreport.ReportLogType AS ENUM (
'created',
'invalidated',
'message-email',
'message-text',
'reviewed',
'scheduled',
'treated'
);
CREATE TABLE publicreport.report_log (
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
email_log_id INTEGER REFERENCES comms.email_log(id),
id SERIAL NOT NULL,
report_id INTEGER NOT NULL REFERENCES publicreport.report(id),
text_log_id INTEGER REFERENCES comms.text_log(id),
type_ publicreport.ReportLogType NOT NULL,
user_id INTEGER REFERENCES user_(id),
PRIMARY KEY (id)
);
INSERT INTO publicreport.report_log (
created,
email_log_id,
report_id,
text_log_id,
type_,
user_id
)
SELECT
created,
NULL,
id,
NULL,
'created',
NULL
FROM publicreport.report;
-- +goose Down
DROP TABLE publicreport.report_log;
DROP TYPE publicreport.ReportLogType;