Skip to content

Instantly share code, notes, and snippets.

@chit-uob
Created January 5, 2023 15:04
Show Gist options
  • Save chit-uob/1257c9e959e92b0f60d98bb9da8b7c72 to your computer and use it in GitHub Desktop.
Save chit-uob/1257c9e959e92b0f60d98bb9da8b7c72 to your computer and use it in GitHub Desktop.
Set up todo list for Supabase Svelte Todo List example
--
-- For use with:
-- https://github.com/supabase/supabase/tree/master/examples/todo-list/nextjs-todo-list or
-- https://github.com/supabase/supabase/tree/master/examples/todo-list/react-todo-list or
-- https://github.com/supabase/supabase/tree/master/examples/todo-list/sveltejs-todo-list or
-- https://github.com/supabase/supabase/tree/master/examples/todo-list/vue3-ts-todo-list
--
create table todos (
id bigint generated by default as identity primary key,
user_id uuid references auth.users not null,
task text check (char_length(task) > 3),
is_complete boolean default false,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
);
alter table todos enable row level security;
create policy "Individuals can create todos." on todos for
insert with check (auth.uid() = user_id);
create policy "Individuals can view their own todos. " on todos for
select using (auth.uid() = user_id);
create policy "Individuals can update their own todos." on todos for
update using (auth.uid() = user_id);
create policy "Individuals can delete their own todos." on todos for
delete using (auth.uid() = user_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment