init commit,
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* USERS
|
||||
* Note: This table contains user data. Users should only be able to view and update their own data.
|
||||
*/
|
||||
create table users (
|
||||
-- UUID from auth.users
|
||||
id uuid references auth.users not null primary key,
|
||||
full_name text,
|
||||
avatar_url text
|
||||
);
|
||||
alter table users enable row level security;
|
||||
create policy "Can view own user data." on users for select using (auth.uid() = id);
|
||||
create policy "Can update own user data." on users for update using (auth.uid() = id);
|
||||
|
||||
/**
|
||||
* This trigger automatically creates a user entry when a new user signs up via Supabase Auth.
|
||||
*/
|
||||
create function public.handle_new_user()
|
||||
returns trigger as $$
|
||||
begin
|
||||
insert into public.users (id, full_name, avatar_url)
|
||||
values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url');
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql security definer;
|
||||
create trigger on_auth_user_created
|
||||
after insert on auth.users
|
||||
for each row execute procedure public.handle_new_user();
|
@@ -0,0 +1,12 @@
|
||||
create table discord_promise_challenge (
|
||||
id bigint generated by default as identity primary key,
|
||||
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null,
|
||||
updated_at timestamp with time zone default timezone('utc'::text, now()) not null,
|
||||
user_id text not null,
|
||||
username text not null,
|
||||
promise text not null,
|
||||
email text,
|
||||
submission text,
|
||||
resolved boolean default false
|
||||
);
|
||||
alter table discord_promise_challenge enable row level security;
|
@@ -0,0 +1,8 @@
|
||||
create table
|
||||
public.sentry_functions_challenge (
|
||||
id bigint generated by default as identity,
|
||||
created_at timestamp with time zone not null default now(),
|
||||
twitter text null,
|
||||
constraint sentry_functions_challenge_pkey primary key (id)
|
||||
) tablespace;
|
||||
alter table public.sentry_functions_challenge enable row level security;
|
Reference in New Issue
Block a user