db: migration session_default_notes_field + schema regenerado
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>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
-- Indexes
|
||||
-- Gerado automaticamente em 2026-04-21T23:16:34.961Z
|
||||
-- Total: 361
|
||||
-- Gerado automaticamente em 2026-05-11T16:53:50.934Z
|
||||
-- Total: 372
|
||||
|
||||
CREATE INDEX agenda_bloqueios_owner_data_idx ON public.agenda_bloqueios USING btree (owner_id, data_inicio, data_fim);
|
||||
|
||||
@@ -184,6 +184,8 @@ CREATE INDEX idx_audit_logs_user_created ON public.audit_logs USING btree (user_
|
||||
|
||||
CREATE INDEX idx_autoreply_log_cooldown ON public.conversation_autoreply_log USING btree (tenant_id, thread_key, sent_at DESC);
|
||||
|
||||
CREATE INDEX idx_bot_sessions_tenant_status ON public.conversation_bot_sessions USING btree (tenant_id, status, started_at DESC);
|
||||
|
||||
CREATE INDEX idx_contact_email_types_tenant ON public.contact_email_types USING btree (tenant_id, "position");
|
||||
|
||||
CREATE INDEX idx_contact_emails_email ON public.contact_emails USING btree (tenant_id, email);
|
||||
@@ -196,6 +198,10 @@ CREATE INDEX idx_contact_phones_number ON public.contact_phones USING btree (ten
|
||||
|
||||
CREATE INDEX idx_contact_types_tenant ON public.contact_types USING btree (tenant_id, "position");
|
||||
|
||||
CREATE INDEX idx_conv_assign_patient ON public.conversation_assignments USING btree (patient_id) WHERE (patient_id IS NOT NULL);
|
||||
|
||||
CREATE INDEX idx_conv_assign_tenant_user ON public.conversation_assignments USING btree (tenant_id, assigned_to) WHERE (assigned_to IS NOT NULL);
|
||||
|
||||
CREATE INDEX idx_conv_msg_delivery_status ON public.conversation_messages USING btree (tenant_id, delivery_status) WHERE (direction = 'outbound'::text);
|
||||
|
||||
CREATE INDEX idx_conv_msg_from_number ON public.conversation_messages USING btree (tenant_id, from_number);
|
||||
@@ -332,6 +338,8 @@ CREATE INDEX idx_intakes_owner_created ON public.patient_intake_requests USING b
|
||||
|
||||
CREATE INDEX idx_intakes_owner_status_created ON public.patient_intake_requests USING btree (owner_id, status, created_at DESC);
|
||||
|
||||
CREATE INDEX idx_intakes_progress_pending ON public.patient_intake_requests USING btree (last_progress_at) WHERE (status = 'in_progress'::text);
|
||||
|
||||
CREATE INDEX idx_intakes_status_created ON public.patient_intake_requests USING btree (status, created_at DESC);
|
||||
|
||||
CREATE INDEX idx_mc_expires ON public.math_challenges USING btree (expires_at);
|
||||
@@ -460,6 +468,10 @@ CREATE INDEX idx_services_name_trgm ON public.services USING gin (name public.gi
|
||||
|
||||
CREATE INDEX idx_session_reminder_tenant_sent ON public.session_reminder_logs USING btree (tenant_id, sent_at DESC);
|
||||
|
||||
CREATE INDEX idx_sla_breaches_open ON public.conversation_sla_breaches USING btree (resolved_at) WHERE (resolved_at IS NULL);
|
||||
|
||||
CREATE INDEX idx_sla_breaches_tenant_breached ON public.conversation_sla_breaches USING btree (tenant_id, breached_at DESC);
|
||||
|
||||
CREATE INDEX idx_slots_bloq_owner_dia ON public.agenda_slots_bloqueados_semanais USING btree (owner_id, dia_semana);
|
||||
|
||||
CREATE INDEX idx_srl_blocked_until ON public.submission_rate_limits USING btree (blocked_until) WHERE (blocked_until IS NOT NULL);
|
||||
@@ -506,6 +518,10 @@ CREATE INDEX idx_wa_credits_tx_kind ON public.whatsapp_credits_transactions USIN
|
||||
|
||||
CREATE INDEX idx_wa_credits_tx_tenant_created ON public.whatsapp_credits_transactions USING btree (tenant_id, created_at DESC);
|
||||
|
||||
CREATE INDEX idx_wa_incidents_open ON public.whatsapp_connection_incidents USING btree (resolved_at) WHERE (resolved_at IS NULL);
|
||||
|
||||
CREATE INDEX idx_wa_incidents_tenant_started ON public.whatsapp_connection_incidents USING btree (tenant_id, started_at DESC);
|
||||
|
||||
CREATE INDEX insurance_plans_owner_idx ON public.insurance_plans USING btree (owner_id);
|
||||
|
||||
CREATE INDEX insurance_plans_tenant_idx ON public.insurance_plans USING btree (tenant_id);
|
||||
@@ -684,6 +700,8 @@ CREATE INDEX tenant_modules_owner_idx ON public.tenant_modules USING btree (owne
|
||||
|
||||
CREATE UNIQUE INDEX unique_member_per_tenant ON public.tenant_members USING btree (tenant_id, user_id);
|
||||
|
||||
CREATE UNIQUE INDEX uq_bot_sessions_active_per_thread ON public.conversation_bot_sessions USING btree (tenant_id, thread_key) WHERE (status = 'active'::text);
|
||||
|
||||
CREATE UNIQUE INDEX uq_contact_email_types_system_slug ON public.contact_email_types USING btree (slug) WHERE (tenant_id IS NULL);
|
||||
|
||||
CREATE UNIQUE INDEX uq_contact_email_types_tenant_slug ON public.contact_email_types USING btree (tenant_id, slug) WHERE (tenant_id IS NOT NULL);
|
||||
@@ -712,6 +730,8 @@ CREATE UNIQUE INDEX uq_plan_prices_active ON public.plan_prices USING btree (pla
|
||||
|
||||
CREATE UNIQUE INDEX uq_session_reminder_event_type ON public.session_reminder_logs USING btree (event_id, reminder_type);
|
||||
|
||||
CREATE UNIQUE INDEX uq_sla_breaches_open_per_thread ON public.conversation_sla_breaches USING btree (tenant_id, thread_key) WHERE (resolved_at IS NULL);
|
||||
|
||||
CREATE UNIQUE INDEX uq_subscriptions_active_by_tenant ON public.subscriptions USING btree (tenant_id) WHERE ((tenant_id IS NOT NULL) AND (status = 'active'::text));
|
||||
|
||||
CREATE UNIQUE INDEX uq_subscriptions_active_personal_by_user ON public.subscriptions USING btree (user_id) WHERE ((tenant_id IS NULL) AND (status = 'active'::text));
|
||||
@@ -720,6 +740,8 @@ CREATE UNIQUE INDEX uq_tenant_invites_pending ON public.tenant_invites USING btr
|
||||
|
||||
CREATE UNIQUE INDEX uq_tenant_members_tenant_user ON public.tenant_members USING btree (tenant_id, user_id);
|
||||
|
||||
CREATE UNIQUE INDEX uq_wa_incidents_open_per_channel ON public.whatsapp_connection_incidents USING btree (channel_id) WHERE (resolved_at IS NULL);
|
||||
|
||||
CREATE UNIQUE INDEX ux_subscriptions_active_per_personal_user ON public.subscriptions USING btree (user_id) WHERE ((status = 'active'::text) AND (tenant_id IS NULL));
|
||||
|
||||
CREATE UNIQUE INDEX ux_subscriptions_active_per_tenant ON public.subscriptions USING btree (tenant_id) WHERE ((status = 'active'::text) AND (tenant_id IS NOT NULL));
|
||||
|
||||
Reference in New Issue
Block a user