-- Migration: InitOutboxes
-- Created at: 17/05/2025 19:58:00

CREATE TABLE blog.outbox
(

    id            uuid PRIMARY KEY,
    event_type    text                    NOT NULL,
    aggregate_id  uuid                    NOT NULL,
    payload       text                    NOT NULL,
    created_at    timestamp DEFAULT now() NOT NULL,
    processed_at  timestamp,
    next_retry_at timestamp,
    retry_count   int       DEFAULT 0     NOT NULL,
    last_error    text,
    status        int       DEFAULT 0     NOT NULL
);

CREATE TABLE authn.outbox
(

    id            uuid PRIMARY KEY,
    event_type    text                    NOT NULL,
    aggregate_id  uuid                    NOT NULL,
    payload       text                    NOT NULL,
    created_at    timestamp DEFAULT now() NOT NULL,
    processed_at  timestamp,
    next_retry_at timestamp,
    retry_count   int       DEFAULT 0     NOT NULL,
    last_error    text,
    status        int       DEFAULT 0     NOT NULL
);

