SQL — RODE NO SUPABASE SQL EDITOR
create table obras (
id uuid default gen_random_uuid() primary key,
nome text not null,
cidade text,
cep text,
endereco text,
tipo text,
raio integer default 100,
area numeric,
obs text,
criada_em timestamptz default now()
);
create table materiais (
id uuid default gen_random_uuid() primary key,
obra_id uuid references obras(id) on delete cascade,
nome text not null,
categoria text,
quantidade numeric,
unidade text,
criada_em timestamptz default now()
);
create table cotacoes (
id uuid default gen_random_uuid() primary key,
obra_id uuid references obras(id) on delete cascade,
fornecedor jsonb not null,
itens jsonb,
frete numeric default 0,
total numeric default 0,
prazo_dias integer,
observacoes text,
status text default 'pendente',
criada_em timestamptz default now()
);
-- Habilitar RLS (Row Level Security) — acesso público para protótipo
alter table obras enable row level security;
alter table materiais enable row level security;
alter table cotacoes enable row level security;
create policy "acesso publico obras" on obras for all using (true) with check (true);
create policy "acesso publico materiais" on materiais for all using (true) with check (true);
create policy "acesso publico cotacoes" on cotacoes for all using (true) with check (true);