-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME_SQL.sql
More file actions
36 lines (32 loc) · 1.72 KB
/
README_SQL.sql
File metadata and controls
36 lines (32 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
create extension if not exists "pgcrypto";
create extension if not exists "uuid-ossp";
create table if not exists public.draws (
id uuid primary key default gen_random_uuid(),
numbers int[] not null check (array_length(numbers,1)=6),
created_at timestamptz not null default now()
);
create index if not exists idx_draws_created_at on public.draws(created_at desc);
alter table public.draws enable row level security;
create policy if not exists "draws_read" on public.draws for select using (true);
create policy if not exists "draws_insert" on public.draws for insert with check (true);
create policy if not exists "draws_delete" on public.draws for delete using (true);
create table if not exists public.kr_lotto_results (
round int primary key,
draw_date date not null,
n1 int not null, n2 int not null, n3 int not null,
n4 int not null, n5 int not null, n6 int not null,
bonus int not null,
first_prize_winners int null,
first_prize_amount numeric null
);
create index if not exists idx_lotto_results_round on public.kr_lotto_results(round);
alter table public.kr_lotto_results enable row level security;
drop policy if exists lotto_read on public.kr_lotto_results;
drop policy if exists lotto_insert on public.kr_lotto_results;
drop policy if exists lotto_update on public.kr_lotto_results;
drop policy if exists lotto_delete on public.kr_lotto_results;
create policy lotto_read on public.kr_lotto_results for select using (true);
create policy lotto_insert on public.kr_lotto_results for insert with check (true);
create policy lotto_update on public.kr_lotto_results for update using (true) with check (true);
create policy lotto_delete on public.kr_lotto_results for delete using (true);
notify pgrst, 'reload schema';