-- Licitações salvas por cliente
CREATE TABLE IF NOT EXISTS licitacoes_cliente (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
documento TEXT NOT NULL, id_licitacao TEXT NOT NULL,
titulo TEXT, orgao TEXT, objeto TEXT, modalidade TEXT, uf TEXT,
abertura TEXT, publicacao TEXT, encerramento TEXT, situacao TEXT,
fonte TEXT DEFAULT 'manual', municipio TEXT, edital_titulo TEXT, esfera TEXT, processo TEXT,
valor TEXT, link TEXT, link_externo TEXT,
fase TEXT DEFAULT 'analise', tags TEXT[] DEFAULT ARRAY[]::TEXT[],
observacoes TEXT DEFAULT '', favorito BOOLEAN DEFAULT false,
empresa_cnpj TEXT,
criado_em TIMESTAMPTZ DEFAULT NOW(), atualizado_em TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(documento, id_licitacao)
);
ALTER TABLE licitacoes_cliente ENABLE ROW LEVEL SECURITY;
ALTER TABLE licitacoes_cliente
ADD COLUMN IF NOT EXISTS publicacao text,
ADD COLUMN IF NOT EXISTS encerramento text,
ADD COLUMN IF NOT EXISTS situacao text,
ADD COLUMN IF NOT EXISTS fonte text DEFAULT 'manual',
ADD COLUMN IF NOT EXISTS municipio text,
ADD COLUMN IF NOT EXISTS edital_titulo text,
ADD COLUMN IF NOT EXISTS esfera text,
ADD COLUMN IF NOT EXISTS processo text,
ADD COLUMN IF NOT EXISTS empresa_cnpj text;
-- Documentos do cliente
CREATE TABLE IF NOT EXISTS documentos_cliente (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
documento TEXT NOT NULL, nome TEXT NOT NULL, categoria TEXT NOT NULL,
validade DATE, status TEXT DEFAULT 'regular', arquivo_url TEXT,
criado_em TIMESTAMPTZ DEFAULT NOW()
);
ALTER TABLE documentos_cliente ENABLE ROW LEVEL SECURITY;
-- Agenda/lembretes
CREATE TABLE IF NOT EXISTS agenda_cliente (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
documento TEXT NOT NULL, titulo TEXT NOT NULL, descricao TEXT,
data_hora TIMESTAMPTZ NOT NULL, tipo TEXT DEFAULT 'lembrete',
id_licitacao TEXT, concluido BOOLEAN DEFAULT false,
criado_em TIMESTAMPTZ DEFAULT NOW()
);
ALTER TABLE agenda_cliente ENABLE ROW LEVEL SECURITY;
-- Tags
CREATE TABLE IF NOT EXISTS tags_cliente (
id TEXT PRIMARY KEY DEFAULT gen_random_uuid()::text,
documento TEXT NOT NULL, nome TEXT NOT NULL, cor TEXT DEFAULT '#E8B420',
criado_em TIMESTAMPTZ DEFAULT NOW()
);
ALTER TABLE tags_cliente ENABLE ROW LEVEL SECURITY;
-- Uso (contador de mensagens e tokens)
CREATE TABLE IF NOT EXISTS uso_clientes (
documento TEXT PRIMARY KEY, msgs INTEGER DEFAULT 0, tokens INTEGER DEFAULT 0,
atualizado_em TIMESTAMPTZ DEFAULT NOW()
);
ALTER TABLE uso_clientes ENABLE ROW LEVEL SECURITY;
-- Multi-empresa por cliente
CREATE TABLE IF NOT EXISTS empresas_cliente (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
cliente_doc text NOT NULL,
nome text NOT NULL,
cnpj text,
drive_url text,
razao_social text,
telefone text,
email text,
perfil_documentos jsonb DEFAULT '{}'::jsonb,
perfil_atualizado_em timestamptz,
created_at timestamptz DEFAULT now()
);
-- Se a tabela ja existir, adicionar colunas do perfil:
ALTER TABLE empresas_cliente
ADD COLUMN IF NOT EXISTS razao_social text,
ADD COLUMN IF NOT EXISTS telefone text,
ADD COLUMN IF NOT EXISTS email text,
ADD COLUMN IF NOT EXISTS perfil_documentos jsonb DEFAULT '{}'::jsonb,
ADD COLUMN IF NOT EXISTS perfil_atualizado_em timestamptz;
CREATE TABLE IF NOT EXISTS documentos_empresa (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
empresa_id uuid REFERENCES empresas_cliente(id) ON DELETE CASCADE,
cliente_doc text NOT NULL,
nome text NOT NULL,
tipo text,
url text,
tamanho text,
created_at timestamptz DEFAULT now()
);
ALTER TABLE empresas_cliente ENABLE ROW LEVEL SECURITY;
ALTER TABLE documentos_empresa ENABLE ROW LEVEL SECURITY;
-- Engenheiro responsavel por empresa (PDF / RT)
CREATE TABLE IF NOT EXISTS engenheiros (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
empresa_cnpj text NOT NULL,
nome text NOT NULL,
registro_crea_cau text,
especialidade text,
email text,
telefone text,
ativo boolean DEFAULT true,
created_at timestamptz DEFAULT now()
);
ALTER TABLE engenheiros ENABLE ROW LEVEL SECURITY;
3
Após executar, clique em Confirmar e Continuar
Dashboard
Clientes Cadastrados
Empresa
Documento
Plano
Trial
Agentes
USO
Ações
Carregando…
Agentes IA
🏛️ Licitações Recentes
📅 Agenda do Dia
📄 Docs. Atenção
⚡ Acesso Rápido — Agentes IA
🔍
🏛️
Busque licitações no PNCP em tempo real
Fonte oficial PNCP — palavra-chave usa a mesma busca do portal nacional.
🏢 Minhas Empresas
⚙️ Configurar Empresa
Todos os dados da empresa — usados em documentos, propostas e pelo assistente IA.
Cadastro 0%
📍 Endereço
📞 Contato
👤 Representante legal
✅ Declarações padrão (referência para a IA)
Responsável técnico desta empresa — usado nos PDFs (memoriais, projetos CAD).