58 lines
2.7 KiB
SQL
58 lines
2.7 KiB
SQL
-- ============================================================
|
|
-- Migration 002 — SetupWizard1: campos Negócio e Atendimento
|
|
-- ============================================================
|
|
-- Tabela: tenants (Step 2 — Negócio)
|
|
-- Tabela: agenda_configuracoes (Step 3 — Atendimento)
|
|
-- ============================================================
|
|
|
|
-- ----------------------------------------------------------
|
|
-- tenants: dados do negócio
|
|
-- ----------------------------------------------------------
|
|
|
|
ALTER TABLE public.tenants
|
|
ADD COLUMN IF NOT EXISTS business_type text,
|
|
ADD COLUMN IF NOT EXISTS logo_url text,
|
|
ADD COLUMN IF NOT EXISTS address text,
|
|
ADD COLUMN IF NOT EXISTS phone text,
|
|
ADD COLUMN IF NOT EXISTS contact_email text,
|
|
ADD COLUMN IF NOT EXISTS site_url text,
|
|
ADD COLUMN IF NOT EXISTS social_instagram text;
|
|
|
|
-- Valores aceitos: consultorio | clinica | instituto | grupo
|
|
ALTER TABLE public.tenants
|
|
ADD CONSTRAINT tenants_business_type_check
|
|
CHECK (business_type IS NULL OR business_type = ANY (ARRAY[
|
|
'consultorio'::text,
|
|
'clinica'::text,
|
|
'instituto'::text,
|
|
'grupo'::text
|
|
]));
|
|
|
|
-- ----------------------------------------------------------
|
|
-- agenda_configuracoes: modo de atendimento
|
|
-- ----------------------------------------------------------
|
|
|
|
ALTER TABLE public.agenda_configuracoes
|
|
ADD COLUMN IF NOT EXISTS atendimento_mode text DEFAULT 'particular'::text;
|
|
|
|
ALTER TABLE public.agenda_configuracoes
|
|
ADD CONSTRAINT agenda_configuracoes_atendimento_mode_check
|
|
CHECK (atendimento_mode IS NULL OR atendimento_mode = ANY (ARRAY[
|
|
'particular'::text,
|
|
'convenio'::text,
|
|
'ambos'::text
|
|
]));
|
|
|
|
-- ----------------------------------------------------------
|
|
-- Comments
|
|
-- ----------------------------------------------------------
|
|
|
|
COMMENT ON COLUMN public.tenants.business_type IS 'Tipo de negócio: consultorio, clinica, instituto, grupo';
|
|
COMMENT ON COLUMN public.tenants.logo_url IS 'URL da logo do negócio (Storage bucket)';
|
|
COMMENT ON COLUMN public.tenants.address IS 'Endereço do negócio (texto livre)';
|
|
COMMENT ON COLUMN public.tenants.phone IS 'Telefone/WhatsApp do negócio';
|
|
COMMENT ON COLUMN public.tenants.contact_email IS 'E-mail público de contato do negócio';
|
|
COMMENT ON COLUMN public.tenants.site_url IS 'Site do negócio';
|
|
COMMENT ON COLUMN public.tenants.social_instagram IS 'Instagram do negócio (sem @)';
|
|
COMMENT ON COLUMN public.agenda_configuracoes.atendimento_mode IS 'Modo de atendimento: particular | convenio | ambos';
|