mirror of
https://github.com/ngthanhvu/kr-phim.git
synced 2026-08-10 13:07:47 +00:00
Add database migration snapshots for comment_votes, comments, movies, and users tables
- Created 0009_snapshot.json with initial structure for comment_votes, comments, movies, and users tables. - Created 0010_snapshot.json with updated structure for comments, including new fields: pinned and spoiler. - Created 0011_snapshot.json with further updates to comments, adding anonymous field and refining existing structures.
This commit is contained in:
@@ -102,3 +102,33 @@ with check (auth.uid() = user_id);
|
||||
create policy "Users can delete own watch later movies"
|
||||
on public.watch_later_movies for delete
|
||||
using (auth.uid() = user_id);
|
||||
|
||||
create table public.comments (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
user_id uuid not null references auth.users(id) on delete cascade,
|
||||
source text not null default '',
|
||||
slug text not null,
|
||||
movie_name text,
|
||||
content text not null,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
alter table public.comments enable row level security;
|
||||
|
||||
create policy "Anyone can read comments"
|
||||
on public.comments for select
|
||||
using (true);
|
||||
|
||||
create policy "Authenticated users can insert comments"
|
||||
on public.comments for insert
|
||||
with check (auth.uid() = user_id);
|
||||
|
||||
create policy "Users can update own comments"
|
||||
on public.comments for update
|
||||
using (auth.uid() = user_id)
|
||||
with check (auth.uid() = user_id);
|
||||
|
||||
create policy "Users can delete own comments"
|
||||
on public.comments for delete
|
||||
using (auth.uid() = user_id);
|
||||
|
||||
Reference in New Issue
Block a user