71 lines
2.3 KiB
SQL
71 lines
2.3 KiB
SQL
-- ==========================================================================
|
|
-- Agência PSI — Migração: remove check constraints dos novos campos
|
|
-- ==========================================================================
|
|
-- Arquivo: supabase/migrations/20260328000003_patients_drop_check_constraints.sql
|
|
-- Criado por: Leonardo Nohama · 2026 · São Carlos/SP
|
|
--
|
|
-- O banco tinha CHECK constraints nos novos campos que foram adicionados
|
|
-- pela migration anterior (ou que já existiam no schema ao vivo).
|
|
-- O frontend já controla os valores via Select com opções fixas,
|
|
-- então os constraints são desnecessários e serão removidos.
|
|
-- ==========================================================================
|
|
|
|
-- canal_preferido
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_canal_preferido_check;
|
|
|
|
-- horario_contato
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_horario_contato_check;
|
|
|
|
-- pronomes
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_pronomes_check;
|
|
|
|
-- nome_social
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_nome_social_check;
|
|
|
|
-- etnia
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_etnia_check;
|
|
|
|
-- convenio
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_convenio_check;
|
|
|
|
-- metodo_pagamento_preferido
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_metodo_pagamento_preferido_check;
|
|
|
|
-- motivo_saida
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_motivo_saida_check;
|
|
|
|
-- status (já ajustado na migration anterior, mas garante)
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_status_check;
|
|
|
|
ALTER TABLE public.patients
|
|
ADD CONSTRAINT patients_status_check CHECK (
|
|
status = ANY (ARRAY[
|
|
'Ativo'::text,
|
|
'Em espera'::text,
|
|
'Inativo'::text,
|
|
'Alta'::text,
|
|
'Encaminhado'::text,
|
|
'Arquivado'::text
|
|
])
|
|
);
|
|
|
|
-- patient_scope (já ajustado na migration anterior, mas garante)
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_patient_scope_check;
|
|
|
|
ALTER TABLE public.patients
|
|
DROP CONSTRAINT IF EXISTS patients_therapist_scope_consistency;
|
|
|
|
-- ==========================================================================
|
|
-- FIM DA MIGRAÇÃO
|
|
-- ==========================================================================
|