Skip to content

Commit dc333ec

Browse files
committed
Formats the demo schema
1 parent 0b0afe0 commit dc333ec

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

example/next-storage/README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Database schema
88

99
```sql
10+
-- Create a table for Public Profiles
1011
create table profiles (
1112
id uuid references auth.users not null,
1213
updated_at timestamp with time zone,
@@ -18,10 +19,20 @@ create table profiles (
1819
unique(username),
1920
constraint username_length check (char_length(username) >= 3)
2021
);
22+
2123
alter table profiles enable row level security;
22-
create policy "Public profiles are viewable by everyone." on profiles for select using (true);
23-
create policy "Users can insert their own profile." on profiles for insert with check (auth.uid() = id);
24-
create policy "Users can update own profile." on profiles for update using (auth.uid() = id);
24+
25+
create policy "Public profiles are viewable by everyone."
26+
on profiles for select
27+
using ( true );
28+
29+
create policy "Users can insert their own profile."
30+
on profiles for insert
31+
with check ( auth.uid() = id );
32+
33+
create policy "Users can update own profile."
34+
on profiles for update
35+
using ( auth.uid() = id );
2536

2637
-- Set up Realtime!
2738
begin;
@@ -31,7 +42,14 @@ commit;
3142
alter publication supabase_realtime add table profiles;
3243

3344
-- Set up Storage!
34-
insert into storage.buckets (id, name) values ('avatars', 'avatars');
35-
create policy "Avatar images are publicly accessible." on storage.objects for select using ( bucket_id = 'avatars' );
36-
create policy "Anyone can upload an avatar." on storage.objects for insert with check ( bucket_id = 'avatars' );
45+
insert into storage.buckets (id, name)
46+
values ('avatars', 'avatars');
47+
48+
create policy "Avatar images are publicly accessible."
49+
on storage.objects for select
50+
using ( bucket_id = 'avatars' );
51+
52+
create policy "Anyone can upload an avatar."
53+
on storage.objects for insert
54+
with check ( bucket_id = 'avatars' );
3755
```

0 commit comments

Comments
 (0)