Simple Todo
Simple todo list app using Next.js and Supabase.
Table schema
-- Create messages table
create table if not exists public.tasks (
id uuid not null primary key default uuid_generate_v4(),
user_id uuid not null references auth.users(id) default auth.uid(),
content text not null,
is_done boolean not null default false,
created_at timestamp with time zone default timezone('utc' :: text, now()) not null
);
-- Set row level security
alter table public.tasks enable row level security;
create policy "Users can view their tasks" on public.tasks for select using (auth.uid = user_id);
create policy "Users can create new tasks" on public.tasks for insert with check (auth.uid = user_id);
create policy "Users can update their tasks" on public.tasks for insert with check (auth.uid = user_id) using (auth.uid = user_id);
create policy "Users can delete their tasks" on public.tasks for insert using (auth.uid = user_id);
-- Enable relatime
alter publication supabase_realtime add table public.tasks;
Generating types
You can generate types for your database using the following command
supabase gen types typescript --project-id your_project_id --schema public > lib/database.types.ts