-- 313_approval_requests_table.sql — 304_approval_requests.sql 분리본 (single-statement). asyncpg 러너가 prepared statement 로 처리해 multi-statement 거부 → 1 stmt/파일. 내용 불변.

CREATE TABLE IF NOT EXISTS approval_requests (
    id            BIGSERIAL   PRIMARY KEY,
    user_id       BIGINT      NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    request_type  VARCHAR(40) NOT NULL,   -- 고정 템플릿 슬롯 타입(app 화이트리스트)
    payload       JSONB       NOT NULL,   -- 고정 템플릿 슬롯만
    status        VARCHAR(20) NOT NULL DEFAULT 'pending',  -- pending | approved | rejected (전이 허용)
    requester     VARCHAR(20) NOT NULL,   -- 'eid'
    decided_by    VARCHAR(40),
    decided_at    TIMESTAMPTZ,
    created_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at    TIMESTAMPTZ NOT NULL DEFAULT now()
);
