CREATE TABLE billing_tasks_history (
    history_event_id SERIAL PRIMARY KEY,
    history_user_id uuid NOT NULL,
    history_originator_id text,
    history_action text NOT NULL,
    history_timestamp integer NOT NULL,
    history_comment text,

    session_id text NOT NULL,
    billing_type text NOT NULL,
    user_id uuid NOT NULL,
    bill double precision NOT NULL,
    deposit integer DEFAULT 0,
    state billing_task_state NOT NULL,
    task_status text NOT NULL,
    last_status_update integer DEFAULT 0,
    last_payment_id integer,
    discretization integer DEFAULT 0,
    queue text DEFAULT '',
    next_queue text DEFAULT '',
    meta text,
    exec_context text,
    event_id bigint,
    cashback double precision NOT NULL,

    FOREIGN KEY(user_id) REFERENCES "user"(id)
);
