CREATE TABLE provedor_arquivos (
    id        bigint NOT NULL,
    descricao VARCHAR2(100) NOT NULL,
    situacao  SMALLINT DEFAULT 1 NOT NULL,
    driver    SMALLINT NOT NULL,
    principal SMALLINT NOT NULL,
    config    json
);

ALTER TABLE provedor_arquivos
    ADD CHECK ( situacao IN ( 0, 1 ) );

ALTER TABLE provedor_arquivos
    ADD CHECK ( driver IN ( 1, 2, 3 ) );

ALTER TABLE provedor_arquivos
    ADD CHECK ( principal IN ( 0, 1 ) );

COMMENT ON COLUMN provedor_arquivos.driver IS
    'Driver de hospedagem dos arquivos
1-Banco de Dados
2-Pasta do Servidor
3-AWS - Amazon Web Services
4-Google Drive';
CREATE UNIQUE INDEX provedor_arquivos_principal_unico ON provedor_arquivos 
    ( 
      (situacao,principal)
WHERE
        situacao = 1
    AND principal = 1
    ) 
;