F3 schema-per-tenant: frontend usa tenantDb() pra tabelas tenant
- useTenantDb composable + lib/supabase/tenantClient (tenantDb/tenantSchemaName)
- tenantStore: getters activeTenantSlug/activeTenantSchema; my_tenants() RPC
passa a devolver slug+nome (migration 07)
- codemod scripts/codemod-tenant-db.py: supabase.from('<84 tabelas + 6 views
tenant>') -> tenantDb().from(...) em 139 arquivos (777 chamadas), remove
.eq('tenant_id') das cadeias tenant (173)
- passada manual (4 agentes): remove tenant_id de payloads insert/upsert/update,
selects, .or/.is de defaults; onConflict ajustado pros uniques sem tenant_id
(singletons usam 'singleton'); realtime de tabelas tenant aponta pro schema
do tenant ativo; repos dropam tenant_id defensivamente de payloads externos
- agendaSelects: tenant_id fora do AGENDA_EVENT_SELECT (quebraria PostgREST)
- zero embeds cross-schema (todos FK embeds sao tenant->tenant ou global->global)
- build de producao passa; 67 .js checados
Pendente (fora do escopo F3, sao cross-tenant/anon -> F4/F6):
- AgendadorPublicoPage (anon, resolve tenant por link_slug)
- Saas{Feriados,NotificationTemplates,DocumentTemplates,Whatsapp}Page
(gerenciam defaults do sistema / views cross-tenant)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import { useRouter } from 'vue-router';
|
||||
import { useLayout } from '@/layout/composables/layout';
|
||||
import Menu from 'primevue/menu';
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
import { tenantDb } from '@/lib/supabase/tenantClient';
|
||||
import { useTenantStore } from '@/stores/tenantStore';
|
||||
import { useClinicKPIs } from '@/composables/useClinicKPIs';
|
||||
import FirstResponseCard from '@/components/dashboard/FirstResponseCard.vue';
|
||||
@@ -419,10 +420,9 @@ async function load() {
|
||||
|
||||
try {
|
||||
const [eventosRes, membrosRes, solRes, cadRes] = await Promise.all([
|
||||
supabase
|
||||
.from('agenda_eventos')
|
||||
tenantDb().from('agenda_eventos')
|
||||
.select('id, inicio_em, fim_em, status, modalidade, tipo, titulo, titulo_custom, patient_id, owner_id, recurrence_id, patients(nome_completo)')
|
||||
.eq('tenant_id', tid)
|
||||
|
||||
.gte('inicio_em', mesInicio)
|
||||
.lte('inicio_em', mesFim)
|
||||
.order('inicio_em', { ascending: true }),
|
||||
@@ -432,17 +432,15 @@ async function load() {
|
||||
.eq('tenant_id', tid)
|
||||
.in('role', ['therapist', 'tenant_admin'])
|
||||
.eq('status', 'active'),
|
||||
supabase
|
||||
.from('agendador_solicitacoes')
|
||||
tenantDb().from('agendador_solicitacoes')
|
||||
.select('id, paciente_nome, paciente_sobrenome, tipo, modalidade, data_solicitada, hora_solicitada')
|
||||
.eq('tenant_id', tid)
|
||||
|
||||
.eq('status', 'pendente')
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(10),
|
||||
supabase
|
||||
.from('patient_intake_requests')
|
||||
tenantDb().from('patient_intake_requests')
|
||||
.select('id, nome_completo, status, created_at')
|
||||
.eq('tenant_id', tid)
|
||||
|
||||
.eq('status', 'new')
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(10)
|
||||
|
||||
Reference in New Issue
Block a user