Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Update supabase.sql by refactoring the SQL comments #325

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions supabase.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Create a table for Public Profiles
-- Creating a table for public profiles
create table profiles (
id uuid references auth.users not null,
updated_at timestamp with time zone,
Expand All @@ -23,7 +23,7 @@ create policy "Users can insert their own profile." on profiles
create policy "Users can update own profile." on profiles
for update using (auth.uid() = id);

-- Set up Storage!
-- Setting up the storage
insert into storage.buckets (id, name)
values ('avatars', 'avatars');

Expand All @@ -36,13 +36,14 @@ create policy "Anyone can upload an avatar." on storage.objects
create policy "Anyone can update an avatar." on storage.objects
for update with check (bucket_id = 'avatars');

--Creating a function to handle new users

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--Creating a function to handle new users
-- Creating a function to handle new users

create function public.handle_new_user()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
insert into public.profiles (id, username)
insert into public.profiles (id, username) -- Inserting into the public profiles
values (new.id, new.raw_user_meta_data->>'username');
return new;
end;
Expand All @@ -52,7 +53,7 @@ create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();

-- Create a table for questions
-- Creating a table for questions
create table questions (
id uuid default uuid_generate_v4() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
Expand Down