-- Central recipient rules for OCSentinel weekly organization reports.
-- The '*' organization ID applies to every organization.

BEGIN;

CREATE TABLE IF NOT EXISTS ocsentinel.organization_report_recipient (
    id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    organization_id TEXT NOT NULL,
    organization_name TEXT NOT NULL,
    recipient_email TEXT NOT NULL,
    enabled BOOLEAN NOT NULL DEFAULT TRUE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    UNIQUE (organization_id, recipient_email)
);

INSERT INTO ocsentinel.organization_report_recipient
    (organization_id, organization_name, recipient_email)
VALUES
    ('*', 'Alle Organisationen', 'lg@officecom.it'),
    ('*', 'Alle Organisationen', 'rk@officecom.biz'),
    ('9', 'Mildenberger Verlag', 'dd@officecom.it'),
    ('16', 'Kirsch GmbH', 'dd@officecom.it')
ON CONFLICT (organization_id, recipient_email) DO NOTHING;

COMMIT;
