Selecione o questionário clínico para gerar o link individual de resposta do tutor:
Acesse os dados protegidos na nuvem com e-mail e senha cadastrados.
Crie uma nova credencial no Supabase para isolar seus atendimentos e prontuários.
Execute no SQL Editor para criar a tabela `questionario_respostas` e habilitar o RLS:
CREATE TABLE IF NOT EXISTS public.questionario_respostas (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id uuid DEFAULT auth.uid(),
paciente_id uuid REFERENCES public.pacientes(id) ON DELETE CASCADE,
questionario text,
codigo text,
respostas jsonb,
escore numeric,
created_at timestamptz DEFAULT now()
);
ALTER TABLE public.questionario_respostas ENABLE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "Questionarios acesso individual" ON public.questionario_respostas;
CREATE POLICY "Questionarios acesso individual" ON public.questionario_respostas
FOR ALL USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id);
Transfere todos os tutores, pacientes e atendimentos armazenados atualmente neste computador diretamente para o seu banco Supabase online, preservando o vínculo entre tutores e animais.
Execute no SQL Editor do painel do seu Supabase para criar as tabelas `tutores`, `pacientes` e `atendimentos` com as políticas de Row Level Security (RLS) exigidas:
-- 1. TABELA TUTORES CREATE TABLE IF NOT EXISTS public.tutores ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), user_id uuid DEFAULT auth.uid(), nome text NOT NULL, email text, telefone text, endereco text, mais_sobre_pessoa text, indicacao text, ativo boolean DEFAULT true, created_at timestamptz DEFAULT now() ); -- 2. TABELA PACIENTES CREATE TABLE IF NOT EXISTS public.pacientes ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), user_id uuid DEFAULT auth.uid(), tutor_id uuid REFERENCES public.tutores(id) ON DELETE CASCADE, nome text NOT NULL, especie text NOT NULL, raca text, cor text, pelagem text, data_nascimento date, idade text, peso numeric, mais_sobre_animal text, caixa_sanitaria text, areia_utilizada text, brinquedos text, arranhadores text, locais_altos text, passeios text, comportamento_rua text, congneres text, arousal text, demora_comendo text, aparece_para_sentir text, dimensao_relacao jsonb DEFAULT '[]'::jsonb, motivacao jsonb DEFAULT '[]'::jsonb, demora_consulta text, mudou_pardieiro text, outro_veterinario text, crmv_outro text, ativo boolean DEFAULT true, created_at timestamptz DEFAULT now() ); -- 3. TABELA ATENDIMENTOS CREATE TABLE IF NOT EXISTS public.atendimentos ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), user_id uuid DEFAULT auth.uid(), paciente_id uuid REFERENCES public.pacientes(id) ON DELETE CASCADE, data_atend date, tipo_atendimento text, motivo_consulta text, peso numeric, observacoes text, diagnostico_diferencial text, diagnostico text, exames_solicitados text, prognostico text, enriquecimento_ambiental text, terapia_comportamental text, terapia_psicotropica text, created_at timestamptz DEFAULT now() ); -- 4. HABILITAR ROW LEVEL SECURITY (RLS) ALTER TABLE public.tutores ENABLE ROW LEVEL SECURITY; ALTER TABLE public.pacientes ENABLE ROW LEVEL SECURITY; ALTER TABLE public.atendimentos ENABLE ROW LEVEL SECURITY; -- 5. POLICIES (ISOLAMENTO POR auth.uid() = user_id) DROP POLICY IF EXISTS "Tutores acesso individual" ON public.tutores; CREATE POLICY "Tutores acesso individual" ON public.tutores FOR ALL USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id); DROP POLICY IF EXISTS "Pacientes acesso individual" ON public.pacientes; CREATE POLICY "Pacientes acesso individual" ON public.pacientes FOR ALL USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id); DROP POLICY IF EXISTS "Atendimentos acesso individual" ON public.atendimentos; CREATE POLICY "Atendimentos acesso individual" ON public.atendimentos FOR ALL USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id);