-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-setup.sql
More file actions
48 lines (41 loc) · 1.52 KB
/
Copy pathsupabase-setup.sql
File metadata and controls
48 lines (41 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- ============================================================
-- CONFIGURAÇÃO DO BANCO DE DADOS — App de Testemunhos
-- Copie TODO este arquivo e cole no SQL Editor do Supabase
-- (Painel do projeto → SQL Editor → New query → Run)
-- ============================================================
create table testimonials (
id uuid primary key default gen_random_uuid(),
name text not null,
role_company text,
message text not null,
rating int check (rating between 1 and 5),
approved boolean not null default false,
created_at timestamptz not null default now()
);
-- Ativa segurança em nível de linha (obrigatório no Supabase)
alter table testimonials enable row level security;
-- Qualquer visitante pode ENVIAR um novo testemunho
create policy "Public can submit testimonials"
on testimonials for insert
to anon
with check (true);
-- Qualquer visitante pode LER apenas os testemunhos aprovados (usado pelo widget)
create policy "Public can view approved testimonials"
on testimonials for select
to anon
using (approved = true);
-- Você (logado como admin) pode ver TODOS os testemunhos, incluindo pendentes
create policy "Admins can view all testimonials"
on testimonials for select
to authenticated
using (true);
-- Você (logado como admin) pode aprovar/editar
create policy "Admins can update testimonials"
on testimonials for update
to authenticated
using (true);
-- Você (logado como admin) pode excluir
create policy "Admins can delete testimonials"
on testimonials for delete
to authenticated
using (true);