-- 출입증 발송 outbox: 발송 결과 기록 + 실패건 재발송 추적
-- Hibernate ddl-auto=validate 가 검증하므로 PassDelivery 엔티티와 컬럼명·타입이 일치해야 한다.

CREATE TABLE pass_deliveries (
    id               BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    created_at       TIMESTAMP    NOT NULL,
    updated_at       TIMESTAMP    NOT NULL,
    visit_request_id BIGINT       NOT NULL,
    channel          VARCHAR(20),
    recipient        VARCHAR(120),
    status           VARCHAR(20)  NOT NULL,
    attempts         INTEGER      NOT NULL,
    last_error       VARCHAR(500)
);
CREATE INDEX idx_pd_status ON pass_deliveries (status);
CREATE INDEX idx_pd_visit_request ON pass_deliveries (visit_request_id);
