-- Tables: Central SaaS (docs/FAQ)
-- Gerado automaticamente em 2026-04-21T23:16:34.957Z
-- 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
);
