CREATE GENERATOR GTBCIELO_MERCHANT;

CREATE TABLE TBCIELO_MERCHANT (
    ID                  INTEGER NOT NULL,
    MERCHANT_ID         INTEGER,
    REGISTER_ID         INTEGER,
    STATUS              VARCHAR(10),
    ADQUIRENTE_ID       INTEGER,
    DATA                TIMESTAMP,
    DELETAR             INTEGER DEFAULT 0,
    CLIENTE_ID          INTEGER,
    ACCESS_TOKEN        VARCHAR(300),
    AUTHORIZATION_CODE  VARCHAR(300),
    REFRESH_TOKEN       VARCHAR(300),
    EXPIRES_IN          TIMESTAMP
);

ALTER TABLE TBCIELO_MERCHANT ADD CONSTRAINT PK_TBCIELO_MERCHANT PRIMARY KEY (ID);

CREATE OR ALTER TRIGGER TTBCIELO_MERCHANT_B01I FOR TBCIELO_MERCHANT
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbcielo_merchant,1);
end;