7
7
## Database schema
8
8
9
9
``` sql
10
+ -- Create a table for Public Profiles
10
11
create table profiles (
11
12
id uuid references auth .users not null ,
12
13
updated_at timestamp with time zone ,
@@ -18,10 +19,20 @@ create table profiles (
18
19
unique(username),
19
20
constraint username_length check (char_length(username) >= 3 )
20
21
);
22
+
21
23
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 );
25
36
26
37
-- Set up Realtime!
27
38
begin ;
@@ -31,7 +42,14 @@ commit;
31
42
alter publication supabase_realtime add table profiles;
32
43
33
44
-- 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' );
37
55
```
0 commit comments