Fuxi/supabase/migrations/20231210071842_problems.sql

39 lines
1.5 KiB
MySQL
Raw Normal View History

2023-12-11 15:12:51 +00:00
create table public.problems
(
id bigint generated by default as identity,
title text not null,
description text not null,
type character varying not null,
tags character varying[] null,
author uuid null,
metadata jsonb null,
is_draft boolean null default true,
is_hidden boolean null default false,
created_at timestamp with time zone null default now(),
constraint problems_pkey primary key (id),
constraint problems_author_fkey foreign key (author) references auth.users (id)
2023-12-10 14:54:04 +00:00
) tablespace pg_default;
2023-12-11 15:12:51 +00:00
alter table public.problems
enable row level security;
2023-12-10 14:54:04 +00:00
create policy "Public problems are viewable by everyone." on problems for
2023-12-11 15:12:51 +00:00
select using (true);
create table public.problem_cases
(
id bigint generated by default as identity,
spec jsonb not null,
limitations jsonb not null,
answer jsonb not null,
problem int8 not null,
is_hidden bool not null default true,
constraint problem_cases_pkey primary key (id),
constraint problem_cases_author_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
alter table public.problem_cases
enable row level security;
2023-12-10 14:54:04 +00:00
create policy "Public problem cases are viewable by everyone." on problem_cases for
2023-12-11 15:12:51 +00:00
select using (is_hidden = false);