Jaeden
10/07/2021, 11:23 AMJaeden
10/07/2021, 12:52 PMid
from the auth.users table?
-- create function for adding user to default watchlist
CREATE OR REPLACE FUNCTION give_user_default_watchlist() RETURNS TRIGGER as
$$
BEGIN
insert into public.watchlists(author_id) VALUES (new.id);
return new;
END
$$ language plpgsql security definer;
--Use the function when auth.users gets an insert
drop trigger if exists default_user_watchlist on auth.users;
create trigger default_user_watchlist after insert on auth.users execute procedure give_user_default_watchlist();
jason-lynx
10/08/2021, 3:50 AMJaeden
10/08/2021, 10:22 AMjason-lynx
10/08/2021, 11:02 AMjonhelge
10/08/2021, 11:40 AMlaznic
10/08/2021, 3:18 PMcreate or replace function public.add_region_ranks()
returns void
as $$
declare
player record;
begin
for player in select * from profiles
loop
insert into profiles_ratings (profile_id, region_id, game_mode_id) values (player.id, 1, 1);
end loop;
end;
$$ language plpgsql security definer;
stibbs
10/11/2021, 11:38 PMsql
order by min != 0 desc, inserted_at desc
I thought it would be something like
js
...
.order('min', { "!= 0", ascending: false })
.order('inserted_at', { ascending: false });
stibbs
10/12/2021, 2:04 AMmin
0 values null, is there a way I can do order by nulls last, but NOT also sort min values asc/desc?stibbs
10/12/2021, 2:32 AMunion
the results with the API?Mihai Andrei
10/12/2021, 6:06 AMMihai Andrei
10/12/2021, 6:06 AMstibbs
10/13/2021, 1:35 AMSølve
10/14/2021, 8:55 AMpublic
schema), and want to allow users to change their own name, but not the id (which references auth.id
). I have the following policy:
sql
CREATE POLICY "Users may only view their own data"
ON pub_users FOR SELECT using (
auth.uid() = id
)
And need something similar for an update policy
sql
-- How do I restrict the UPDATE to only be allowed for the `name`-column?
CREATE POLICY "Users may only update their own name"
ON pub_users FOR UPDATE using (
auth.uid() = id
)
chipilov
10/14/2021, 10:04 AMchipilov
10/14/2021, 10:11 AMSølve
10/14/2021, 10:13 AMsql
CREATE OR REPLACE VIEW editable_user AS
SELECT u.name
FROM pub_users u
WHERE auth.uid() = u.id
Sølve
10/14/2021, 10:15 AMchipilov
10/14/2021, 10:27 AMSølve
10/14/2021, 10:36 AMpub_users
in public, and it has RLS enabled with the following policies:
sql
CREATE POLICY "Users may only view their own data"
ON pub_users FOR SELECT using (
auth.uid() = id
)
And my admin-roles (also defined in the pub_users table)
sql
CREATE POLICY "Admin users have full access to user data"
ON pub_users FOR ALL using (is_admin(auth.uid()))
All my DB code is handled (migrated, rolled back, seeded) by knex, connecting with service key. I am now wondering if this means the view will be owned by the service/superadmin. I will certainly have to dig a bit deeper to see if this works in practice!mikebarkmin
10/14/2021, 11:31 AMSølve
10/14/2021, 12:09 PM.env.local
file, and in my GitHub workflows it is stored as a secret. I do not know if this will work for buckets, as my project currently does not use any bucketsmikebarkmin
10/14/2021, 12:13 PMSølve
10/14/2021, 12:15 PMSølve
10/14/2021, 12:17 PMSUPABASE_CONNECTION_STRING=postgres://postgres:postgres@localhost:5432/postgres
Sølve
10/14/2021, 12:17 PMmikebarkmin
10/14/2021, 12:18 PMSølve
10/14/2021, 12:19 PMmikebarkmin
10/14/2021, 12:38 PMkennethcassel
10/20/2021, 5:26 PM