Fuxi/supabase/migrations/20231210135930_challenges.sql

36 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

2023-12-11 15:12:51 +00:00
create table public.challenges
(
id bigint generated by default as identity,
answers jsonb not null,
details jsonb not null,
author uuid not null,
problem int8 not null,
status varchar(256) not null,
created_at timestamp with time zone null default now(),
constraint challenges_pkey primary key (id),
constraint challenges_author_fkey foreign key (author) references auth.users (id),
constraint challenges_problem_fkey foreign key (problem) references public.problems (id)
2023-12-10 14:54:04 +00:00
) tablespace pg_default;
2023-12-11 15:12:51 +00:00
2023-12-10 14:54:04 +00:00
alter table public.challenges enable row level security;
2023-12-11 15:12:51 +00:00
create
policy "Enable insert for everyone" on "public"."challenges"
as permissive for insert
to public
with check (true);
create
policy "Enable read access for users' own items" on "public"."challenges"
as permissive for
select
to public
using (author = auth.uid());
create
policy "Enable update access for users' own items" on "public"."challenges"
as permissive for
update
to public
2023-12-12 12:20:36 +00:00
using (author = auth.uid() and status = 'in-progress')
2023-12-11 15:12:51 +00:00
with check (author = auth.uid())