Site Yönetimi,Kullanıcı Girişi,Karanlık mod özellikleri db bağlantıları.
This commit is contained in:
44
supabase_schema_categories.sql
Normal file
44
supabase_schema_categories.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- 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'
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user