CREATE TABLE TBAPI_INTEGRACAO_TOKEN (
    ID INTEGER NOT NULL,
    API_INTEGRACAO_ID INTEGER,
    ACCESS_TOKEN VARCHAR(200),
    REFRESH_TOKEN VARCHAR(200),
    EXPIRES_IN TIMESTAMP);

ALTER TABLE TBAPI_INTEGRACAO_TOKEN
ADD CONSTRAINT PK_TBAPI_INTEGRACAO_TOKEN
PRIMARY KEY (ID);

CREATE SEQUENCE GTBAPI_INTEGRACAO_TOKEN;

SET TERM ^ ;

create trigger ttbapi_integracao_token_b01i for tbapi_integracao_token
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbapi_integracao_token,1);
end
^

SET TERM ; ^


CREATE INDEX ITBAPI_INTEGRACAO_TOKEN_01
ON TBAPI_INTEGRACAO_TOKEN (API_INTEGRACAO_ID);

CREATE INDEX ITBAPI_INTEGRACAO_TOKEN_02
ON TBAPI_INTEGRACAO_TOKEN (EXPIRES_IN);


ALTER TABLE TBAPI_INTEGRACAO_TOKEN
    ADD EXPIRES_IN_REFRESH_TOKEN TIMESTAMP;

