reserva_chatmotel/supabase/migrations/20260414000003_rls_tenant_scoping.sql
Rodribm10 e912563196 feat: schema multi-tenant (tenants, app_config, tenant_id backfill, RLS)
- Novas tabelas reserva_hotel.tenants e reserva_hotel.app_config
- Coluna tenant_id adicionada em todas as tabelas de catalogo/reservas
- Tenant default 'grupo-1001' criado + backfill das rows existentes
- RLS + grants pro anon ler tenants e app_config
- Types TS regenerados

Aplicado via MCP. Arquivos de migration sao source of truth historica.
2026-04-14 20:59:37 -03:00

17 lines
665 B
SQL

-- RLS + grants pras tabelas publicas de tenant
-- Já aplicada via MCP.
alter table reserva_hotel.tenants enable row level security;
alter table reserva_hotel.app_config enable row level security;
drop policy if exists "public_read_tenants" on reserva_hotel.tenants;
create policy "public_read_tenants" on reserva_hotel.tenants
for select using (ativo = true);
drop policy if exists "public_read_app_config" on reserva_hotel.app_config;
create policy "public_read_app_config" on reserva_hotel.app_config
for select using (true);
grant select on reserva_hotel.tenants to anon, authenticated;
grant select on reserva_hotel.app_config to anon, authenticated;