CREATE TABLE TBPSP_PIX_CONFIG (
    ID INTEGER NOT NULL,
    PSP_PIX_ID INTEGER,
    CHAVE_PIX VARCHAR(500),
    CLIENT_ID VARCHAR(500),
    CLIENT_SECRET VARCHAR(500),
    CERTIFICADO_FILE_PFX BLOB SUB_TYPE 0 SEGMENT SIZE 80,
	CERTIFICADO_FILE_CRT BLOB SUB_TYPE 1 SEGMENT SIZE 80,
	CERTIFICADO_FILE_KEY_CRT BLOB SUB_TYPE 1 SEGMENT SIZE 80,
    CERTIFICADO_NOME VARCHAR(200),
    CERTIFICADO_SENHA VARCHAR(50),
    CERTIFICADO_VALIDADE DATE,
    DEVELOPER_APP_KEY VARCHAR(200),
	AMBIENTE INTEGER DEFAULT 1 NOT NULL,
    STATUS INTEGER DEFAULT 1 NOT NULL,
    DATAHORA TIMESTAMP DEFAULT LOCALTIMESTAMP NOT NULL);

ALTER TABLE TBPSP_PIX_CONFIG
ADD CONSTRAINT PK_TBPSP_PIX_CONFIG
PRIMARY KEY (ID);

COMMENT ON COLUMN TBPSP_PIX_CONFIG.DEVELOPER_APP_KEY IS
'CAMPO UTILIZADO PARA REQUISICOES DO BANCO DO BRASIL';

COMMENT ON COLUMN TBPSP_PIX_CONFIG.STATUS IS
'AMBIENTE PARA PSP PIX:
1 - SANDBOX;
2 - PRODUCAO;';

COMMENT ON COLUMN TBPSP_PIX_CONFIG.AMBIENTE IS
'STATUS DO REGISTRO:
0 - INATIVO;
1 - ATIVO;';

CREATE SEQUENCE GTBPSP_PIX_CONFIG;

SET TERM ^ ;

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

SET TERM ; ^

