--up
CREATE TABLE sendgrid_events (
    id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    "user_id" integer REFERENCES users (id) ON UPDATE RESTRICT ON DELETE CASCADE,
    email text NOT NULL,
    event text,
    source text,
    category text[],
    ip text,
    mc_stats text,
    send_at integer,
    sg_event_id text,
    sg_message_id text,
    sg_template_id text,
    sg_template_name text,
    singlesend_id text,
    singlesend_name text,
    marketing_campaign_id integer,
    marketing_campaign_name text,
    marketing_campaign_version text,
    template_hash text,
    template_id text,
    template_version_id text,
    useragent text,
    created_at timestamp without time zone NOT NULL DEFAULT now()
)

--down
DROP TABLE sendgrid_events;