2026-01-20 17:10:22 +00:00
|
|
|
-- +goose Up
|
|
|
|
|
CREATE SCHEMA comms;
|
2026-01-21 03:30:03 +00:00
|
|
|
CREATE TYPE comms.MessageTypeText AS ENUM (
|
|
|
|
|
'initial-contact',
|
2026-01-20 17:10:22 +00:00
|
|
|
'report-subscription-confirmation',
|
|
|
|
|
'report-status-scheduled',
|
|
|
|
|
'report-status-complete'
|
|
|
|
|
);
|
2026-01-21 03:30:03 +00:00
|
|
|
CREATE TYPE comms.MessageTypeEmail AS ENUM (
|
|
|
|
|
'initial-contact',
|
2026-01-20 17:10:22 +00:00
|
|
|
'report-subscription-confirmation',
|
|
|
|
|
'report-status-scheduled',
|
|
|
|
|
'report-status-complete'
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE comms.phone (
|
|
|
|
|
e164 TEXT NOT NULL,
|
|
|
|
|
is_subscribed BOOLEAN NOT NULL,
|
|
|
|
|
PRIMARY KEY (e164)
|
|
|
|
|
);
|
2026-01-21 03:30:03 +00:00
|
|
|
CREATE TABLE comms.text_log (
|
2026-01-20 17:10:22 +00:00
|
|
|
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
|
|
|
|
destination TEXT NOT NULL REFERENCES comms.phone(e164),
|
|
|
|
|
source TEXT NOT NULL REFERENCES comms.phone(e164),
|
2026-01-21 03:30:03 +00:00
|
|
|
type comms.MessageTypeText NOT NULL,
|
2026-01-20 17:10:22 +00:00
|
|
|
PRIMARY KEY (destination, source, type)
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE comms.email (
|
|
|
|
|
address TEXT NOT NULL,
|
|
|
|
|
confirmed BOOLEAN NOT NULL,
|
|
|
|
|
is_subscribed BOOLEAN NOT NULL,
|
|
|
|
|
PRIMARY KEY(address)
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE comms.email_log (
|
|
|
|
|
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
|
|
|
|
destination TEXT NOT NULL REFERENCES comms.email(address),
|
|
|
|
|
source TEXT NOT NULL REFERENCES comms.phone(e164),
|
2026-01-21 03:30:03 +00:00
|
|
|
type comms.MessageTypeEmail NOT NULL,
|
2026-01-20 17:10:22 +00:00
|
|
|
PRIMARY KEY(destination, source, type)
|
|
|
|
|
);
|
2026-01-21 03:30:03 +00:00
|
|
|
-- +goose Down
|
|
|
|
|
DROP TABLE comms.email_log;
|
|
|
|
|
DROP TABLE comms.email;
|
|
|
|
|
DROP TABLE comms.text_log;
|
|
|
|
|
DROP TABLE comms.phone;
|
|
|
|
|
DROP TYPE comms.MessageTypeEmail;
|
|
|
|
|
DROP TYPE comms.MessageTypeText;
|
|
|
|
|
DROP SCHEMA comms;
|