CREATE TABLE IF NOT EXISTS workspace_billing_history
(
    uid          UUID PRIMARY KEY,
    workspace_id UUID           NOT NULL,
    user_id      UUID,
    amount       DECIMAL(20, 4) NOT NULL,
    currency     VARCHAR(10)    NOT NULL DEFAULT 'USD',
    reason       VARCHAR(100)   NOT NULL,
    extra        JSONB,
    created_at   TIMESTAMPTZ    NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_wsbh_workspace_id ON workspace_billing_history (workspace_id);
CREATE INDEX IF NOT EXISTS idx_wsbh_created_at ON workspace_billing_history (created_at DESC);
