START TRANSACTION;

CREATE TABLE bot_service_reserve
(
    id          BIGSERIAL PRIMARY KEY,
    resource_id BIGINT NOT NULL REFERENCES resource (id) ON UPDATE CASCADE ON DELETE CASCADE,
    segment_id  BIGINT NOT NULL REFERENCES segment (id) ON UPDATE CASCADE ON DELETE CASCADE,
    big_order_id BIGINT NOT NULL REFERENCES bot_big_order (id) ON UPDATE CASCADE ON DELETE CASCADE,
    amount      BIGINT NOT NULL,

    UNIQUE (resource_id, segment_id, big_order_id)
);

COMMIT;
