-- Create categories table create table if not exists categories ( id uuid default gen_random_uuid() primary key, name text not null, slug text not null unique, description text, image_url text, created_at timestamp with time zone default timezone('utc'::text, now()) not null ); -- Enable RLS alter table categories enable row level security; -- Policies create policy "Public categories are viewable by everyone." on categories for select using ( true ); create policy "Admins can insert categories." on categories for insert with check ( exists ( select 1 from profiles where profiles.id = auth.uid() and profiles.role = 'admin' ) ); create policy "Admins can update categories." on categories for update using ( exists ( select 1 from profiles where profiles.id = auth.uid() and profiles.role = 'admin' ) ); create policy "Admins can delete categories." on categories for delete using ( exists ( select 1 from profiles where profiles.id = auth.uid() and profiles.role = 'admin' ) );