CREATE TABLE TBEPC (
    ID INTEGER NOT NULL,
    MODELO_ID INTEGER,
    PRODUTO_ID INTEGER,
    COR_ID INTEGER,
    TAMANHO INTEGER,
    QUANTIDADE INTEGER,
    EPC VARCHAR(300),
    API_ID INTEGER);

ALTER TABLE TBEPC
ADD CONSTRAINT PK_TBEPC
PRIMARY KEY (ID);

CREATE SEQUENCE GTBEPC;

SET TERM ^ ;

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

SET TERM ; ^

ALTER TABLE TBEPC
    ADD VINCULO_ID INTEGER;

CREATE INDEX ITBEPC_06
ON TBEPC (VINCULO_ID);

CREATE INDEX ITBEPC_05
ON TBEPC (EPC);

CREATE INDEX ITBEPC_04
ON TBEPC (TAMANHO);

CREATE INDEX ITBEPC_03
ON TBEPC (PRODUTO_ID);

CREATE INDEX ITBEPC_02
ON TBEPC (COR_ID);

CREATE INDEX ITBEPC_01
ON TBEPC (MODELO_ID);

ALTER TABLE TBEPC
    ADD TALAO_ID INTEGER;

CREATE INDEX ITBEPC_07
ON TBEPC (TALAO_ID);

CREATE TABLE TBAPI_INTEGRACAO_ZONAS (
    ID INTEGER NOT NULL,
    API_ID INTEGER,
    NOME VARCHAR(50),
    URL VARCHAR(200),
    USUARIO VARCHAR(50),
    SENHA VARCHAR(50),
    TIPO INTEGER);

ALTER TABLE TBAPI_INTEGRACAO_ZONAS
ADD CONSTRAINT PK_TBAPI_INTEGRACAO_ZONAS
PRIMARY KEY (ID);

CREATE SEQUENCE GTBAPI_INTEGRACAO_ZONAS;

SET TERM ^ ;

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

SET TERM ; ^

CREATE INDEX ITBAPI_INTEGRACAO_ZONAS_01
ON TBAPI_INTEGRACAO_ZONAS (API_ID);

ALTER TABLE TBAPI_INTEGRACAO_ZONAS
    ADD STATUS INTEGER;

