CREATE GENERATOR GTBPDV_ADQUIRENTE_MERCHANT;

CREATE TABLE TBPDV_ADQUIRENTE_MERCHANT (
    ID                  INTEGER NOT NULL,
    MERCHANT_ID         INTEGER,
    REGISTER_ID         INTEGER,
    STATUS              VARCHAR(30),
    ADQUIRENTE_ID       INTEGER,
    DATA                TIMESTAMP,
    DELETAR             INTEGER DEFAULT 0,
    ACCESS_TOKEN        VARCHAR(300),
    AUTHORIZATION_CODE  VARCHAR(300),
    REFRESH_TOKEN       VARCHAR(300),
    EXPIRES_IN          TIMESTAMP,
    CLIENTE_ID          VARCHAR(50),
    CAIXABANCO_ID       INTEGER,
    ESTABELECIMENTO_ID  INTEGER DEFAULT 0
);

ALTER TABLE TBPDV_ADQUIRENTE_MERCHANT ADD CONSTRAINT PK_TBPDV_ADQUIRENTE_MERCHANT PRIMARY KEY (ID);


SET TERM ^ ;

CREATE OR ALTER TRIGGER TTBPDV_ADQUIRENTE_MERCHANT_B01I FOR TBPDV_ADQUIRENTE_MERCHANT
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gTBPDV_ADQUIRENTE_MERCHANT,1);
end
^

SET TERM ; ^
