7c20b518d4
Repositorio estava ha ~5 sessoes sem commit. Consolida tudo desde d088a89.
Ver commit.md na raiz para descricao completa por sessao.
# Numeros
- A# auditoria abertos: 0/30
- V# verificacoes abertos: 5/52 (todos adiados com plano)
- T# testes escritos: 10/10
- Vitest: 192/192
- SQL integration: 33/33
- E2E (Playwright, novo): 5/5
- Migrations: 17 (10 novas Sessao 6)
- Areas auditadas: 7 (+documentos com 10 V#)
# Highlights Sessao 6 (hoje)
- V#34/V#41 Opcao B2: tenant_features com plano + override (RPC SECURITY DEFINER, tela /saas/tenant-features)
- A#20 rev2 self-hosted: defesa em 5 camadas (honeypot + rate limit + math captcha condicional + paranoid mode + dashboard /saas/security)
- Documentos hardening (V#43-V#49): tenant scoping em storage policies (vazamento entre clinicas eliminado), RPC validate_share_token, signatures policy granular
- SaaS Twilio Config (/saas/twilio-config): UI editavel para SID/webhook/cotacao; AUTH_TOKEN permanece em env var
- T#9 + T#10: useAgendaEvents.spec.js + Playwright E2E (descobriu bug no front que foi corrigido)
# Sessoes anteriores (1-5) consolidadas
- Sessao 1: auth/router/session, normalizeRole extraido
- Sessao 2: agenda - composables/services consolidados
- Sessao 3: pacientes - tenant_id em todas queries
- Sessao 4: security review pagina publica - 14/15 vulnerabilidades corrigidas
- Sessao 5: SaaS - P0 (A#30: 7 tabelas com RLS off corrigidas)
# .gitignore ajustado
- supabase/* + !supabase/functions/ (mantem 10 edge functions, ignora .temp/migrations gerados pelo CLI)
- database-novo/backups/ (regeneravel via db.cjs backup)
- test-results/ + playwright-report/
- .claude/settings.local.json (config local com senha de dev removida do tracking)
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-04-17T12:23:05.229Z
|
|
-- 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()
|
|
);
|