gitlabmerge-request

Is gitlab merge request global id auto increment?


I can use gitlab merge request's API to list merge requests, and find that mr's id behaves auto increment. But I cannot find any document about this feature.

enter image description here

In gitlab source code, this filed is just a integer.

CREATE TABLE merge_requests (
    id integer NOT NULL,
    target_branch character varying NOT NULL,
    source_branch character varying NOT NULL,
    ...

Solution

  • It is indeed an increasing sequence, implemented here.

    Lines 13520-13527:

    CREATE SEQUENCE merge_requests_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
        
    ALTER SEQUENCE merge_requests_id_seq OWNED BY merge_requests.id;
    

    And line 22160:

    ALTER TABLE ONLY merge_requests ALTER COLUMN id SET DEFAULT nextval('merge_requests_id_seq'::regclass);