Files
agenciapsilmno/database-novo/schema/04_tables/central_saas_docs_faq.sql
T
Leonardo dba595fd2d db: migration session_default_notes_field + schema regenerado
Migration 20260511000001 adiciona campo 'notes' (Observacao, textarea,
sort_order=30) como campo extra default no commitment determinado 'Sessao'.
Antes Sessao era a unica excecao entre os nativos — Leitura/Supervisao/
Aula/Analise ja tinham. Padroniza pra que a Observacao da sessao siga o
mesmo mecanismo de extra_fields dos outros, e o frontend remova a textarea
hardcoded do AgendaEventDialog (proximo commit).

Backfill: insere 'notes' em TODOS os commitments Sessao ja existentes
(idempotente). Forward-fix: substitui a funcao seed_determined_commitments
incluindo o bloco de Sessao + 'notes' pra novos tenants.

Schema regenerado via db.cjs schema-export pra refletir o estado pos-
migration. agenciapsi-db-dashboard.html regenerado pelo
generate-dashboard.cjs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 16:56:59 -03:00

62 lines
2.2 KiB
SQL

-- Tables: Central SaaS (docs/FAQ)
-- Gerado automaticamente em 2026-05-11T16:53:50.931Z
-- Total: 4
CREATE TABLE public.saas_doc_votos (
id uuid DEFAULT gen_random_uuid() NOT NULL,
doc_id uuid NOT NULL,
user_id uuid NOT NULL,
util boolean NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL
);
CREATE TABLE public.saas_docs (
id uuid DEFAULT gen_random_uuid() NOT NULL,
titulo text NOT NULL,
conteudo text DEFAULT ''::text NOT NULL,
medias jsonb DEFAULT '[]'::jsonb NOT NULL,
tipo_acesso text DEFAULT 'usuario'::text NOT NULL,
pagina_path text NOT NULL,
docs_relacionados uuid[] DEFAULT '{}'::uuid[] NOT NULL,
ativo boolean DEFAULT true NOT NULL,
ordem integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
categoria text,
exibir_no_faq boolean DEFAULT false NOT NULL,
votos_util integer DEFAULT 0 NOT NULL,
votos_nao_util integer DEFAULT 0 NOT NULL,
CONSTRAINT saas_docs_tipo_acesso_check CHECK ((tipo_acesso = ANY (ARRAY['admin'::text, 'usuario'::text])))
);
CREATE TABLE public.saas_faq (
id uuid DEFAULT gen_random_uuid() NOT NULL,
pergunta text NOT NULL,
categoria text,
publico boolean DEFAULT false NOT NULL,
votos integer DEFAULT 0 NOT NULL,
titulo text,
conteudo text,
tipo_acesso text DEFAULT 'usuario'::text NOT NULL,
pagina_path text NOT NULL,
pagina_label text,
medias jsonb DEFAULT '[]'::jsonb NOT NULL,
faqs_relacionados uuid[] DEFAULT '{}'::uuid[] NOT NULL,
ativo boolean DEFAULT true NOT NULL,
ordem integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL
);
CREATE TABLE public.saas_faq_itens (
id uuid DEFAULT gen_random_uuid() NOT NULL,
doc_id uuid NOT NULL,
pergunta text NOT NULL,
resposta text,
ordem integer DEFAULT 0 NOT NULL,
ativo boolean DEFAULT true NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL
);