dba595fd2d
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>
116 lines
4.0 KiB
SQL
116 lines
4.0 KiB
SQL
-- Tables: Serviços / Prontuários
|
|
-- Gerado automaticamente em 2026-05-11T16:53:50.930Z
|
|
-- Total: 8
|
|
|
|
CREATE TABLE public.commitment_services (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
commitment_id uuid NOT NULL,
|
|
service_id uuid NOT NULL,
|
|
quantity integer DEFAULT 1 NOT NULL,
|
|
unit_price numeric(10,2) NOT NULL,
|
|
discount_pct numeric(5,2) DEFAULT 0,
|
|
discount_flat numeric(10,2) DEFAULT 0,
|
|
final_price numeric(10,2) NOT NULL,
|
|
created_at timestamp with time zone DEFAULT now(),
|
|
CONSTRAINT commitment_services_disc_flat_chk CHECK ((discount_flat >= (0)::numeric)),
|
|
CONSTRAINT commitment_services_disc_pct_chk CHECK (((discount_pct >= (0)::numeric) AND (discount_pct <= (100)::numeric))),
|
|
CONSTRAINT commitment_services_final_price_chk CHECK ((final_price >= (0)::numeric)),
|
|
CONSTRAINT commitment_services_quantity_chk CHECK ((quantity > 0))
|
|
);
|
|
|
|
CREATE TABLE public.commitment_time_logs (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
tenant_id uuid NOT NULL,
|
|
commitment_id uuid NOT NULL,
|
|
calendar_event_id uuid,
|
|
source public.commitment_log_source DEFAULT 'manual'::public.commitment_log_source NOT NULL,
|
|
started_at timestamp with time zone NOT NULL,
|
|
ended_at timestamp with time zone NOT NULL,
|
|
minutes integer NOT NULL,
|
|
created_by uuid,
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
CREATE TABLE public.determined_commitment_fields (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
tenant_id uuid NOT NULL,
|
|
commitment_id uuid NOT NULL,
|
|
key text NOT NULL,
|
|
label text NOT NULL,
|
|
field_type public.determined_field_type DEFAULT 'text'::public.determined_field_type NOT NULL,
|
|
required boolean DEFAULT false NOT NULL,
|
|
sort_order 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.determined_commitments (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
tenant_id uuid NOT NULL,
|
|
created_by uuid,
|
|
is_native boolean DEFAULT false NOT NULL,
|
|
native_key text,
|
|
is_locked boolean DEFAULT false NOT NULL,
|
|
active boolean DEFAULT true NOT NULL,
|
|
name text NOT NULL,
|
|
description text,
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
bg_color text,
|
|
text_color text
|
|
);
|
|
|
|
CREATE TABLE public.insurance_plan_services (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
insurance_plan_id uuid NOT NULL,
|
|
name text NOT NULL,
|
|
value numeric(10,2) NOT NULL,
|
|
active boolean DEFAULT true NOT NULL,
|
|
created_at timestamp with time zone DEFAULT now(),
|
|
updated_at timestamp with time zone DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE public.insurance_plans (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
owner_id uuid NOT NULL,
|
|
tenant_id uuid NOT NULL,
|
|
name text NOT NULL,
|
|
notes text,
|
|
default_value numeric(10,2),
|
|
active boolean DEFAULT true NOT NULL,
|
|
created_at timestamp with time zone DEFAULT now(),
|
|
updated_at timestamp with time zone DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE public.medicos (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
owner_id uuid NOT NULL,
|
|
tenant_id uuid NOT NULL,
|
|
nome text NOT NULL,
|
|
crm text,
|
|
especialidade text,
|
|
telefone_profissional text,
|
|
telefone_pessoal text,
|
|
email text,
|
|
clinica text,
|
|
cidade text,
|
|
estado text DEFAULT 'SP'::text,
|
|
observacoes text,
|
|
ativo boolean DEFAULT true NOT NULL,
|
|
created_at timestamp with time zone DEFAULT now(),
|
|
updated_at timestamp with time zone DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE public.services (
|
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
owner_id uuid NOT NULL,
|
|
tenant_id uuid NOT NULL,
|
|
name text NOT NULL,
|
|
description text,
|
|
price numeric(10,2) NOT NULL,
|
|
duration_min integer,
|
|
active boolean DEFAULT true NOT NULL,
|
|
created_at timestamp with time zone DEFAULT now(),
|
|
updated_at timestamp with time zone DEFAULT now()
|
|
);
|