SETY
08/28/2021, 11:17 PMdrop table if exists user_roles;
drop type if exists custom_user_roles;
CREATE TYPE custom_user_roles AS ENUM ('user','approver','admin');
create table user_roles (
id uuid references auth.users not null unique,
role custom_user_roles not null default 'user',
primary key (id)
);
alter table user_roles enable row level security;
create or replace function add_default_user()
returns trigger as
$$
begin
insert into public.user_roles(id, role) VALUES (NEW.id, 'user');
return NEW;
end;
$$
language 'plpgsql' SECURITY DEFINER;
drop trigger if exists default_user_role on auth.users;
create trigger default_user_role after insert on auth.users execute procedure add_default_user();
SETY
08/28/2021, 11:17 PMSETY
08/28/2021, 11:18 PMHorseShoe
08/29/2021, 3:50 AMsql
WITH folders as
select
storage.foldername(name) as folders
from
storage.objects;
folders [ 0 ] = 'avatar'
and uid() = (
SELECT
rooms.owner
FROM
rooms
WHERE
rooms.id:: text = folders [ 1 ]
)
HorseShoe
08/29/2021, 3:50 AMHorseShoe
08/29/2021, 3:51 AMHorseShoe
08/29/2021, 4:14 AMPeanut
08/29/2021, 5:41 AMCREATE OR REPLACE FUNCTION net."http_post"(
But I get error:
ERROR: cannot remove parameter defaults from existing function
HINT: Use DROP FUNCTION net.http_post(text,jsonb,jsonb,jsonb,integer) first.
When I try to DROP the function I get an error about it being a dependency on the pg_net
extensionSETY
08/29/2021, 10:18 PMsilentworks
08/29/2021, 10:44 PMpublic.users
should not affect auth.users
at all unless you have setup a constraint somewhereburggraf
08/29/2021, 10:45 PMuserprofile
or something like that so I don’t get confused later.JW
08/30/2021, 11:41 AMselect
*
from
calculator_screens
inner join calculator_answers answer on answer.calculator_screen = calculator_screens.id
That's my pure sql query, working fine. I am trying to do the same on the frontend, what would the query look like?
I have a third table calculator_moves
that has a foreign key to a calculator_answer
and to calculator_screens
. Anything I try using postgrest ends in an More than one relationship was found for calculator_screens and calculator_answers
error even though calculator_moves
is never touched
Do i need to use stored procedure to run my query?Peanut
08/30/2021, 12:01 PMsilentworks
08/30/2021, 3:20 PMReza
08/30/2021, 7:24 PMburggraf
08/30/2021, 8:42 PM.rpc()
Miguel2390d
08/31/2021, 3:11 AMMiguel2390d
08/31/2021, 3:12 AMMiguel2390d
08/31/2021, 3:12 AMsql
CREATE POLICY "allow_insert"
ON "CompanySubmissions"
FOR INSERT WITH CHECK (
auth.role() = 'anon'
);
Miguel2390d
08/31/2021, 3:13 AMMiguel2390d
08/31/2021, 3:15 AMjson
{
"code":"42501",
"message":"new row violates row-level security policy for table \"CompanySubmissions\""
}
jason-lynx
08/31/2021, 4:16 AMjason-lynx
08/31/2021, 4:16 AMburggraf
08/31/2021, 1:07 PM.insert
of { returning: 'minimal' }
yurix
08/31/2021, 2:55 PM-- # EXAMPLE TABLES
TABLE public.projects (
id: TEXT
name: TEXT,
)
TABLE public.sheets (
id uuid primary key default uuid_generate_v4(),
project_id not null references public.projects(id)
name: TEXT,
)
-- # EXAMPLE QUERY
const { data, error } = await supabase
.from('sheets')
.select(
*,
project:project_id (
name,
)
)
.match({ "sheets.name": 'sheet_name' })
Currently this returns all the records from the table sheets to me, without filtering anything. Why?yurix
08/31/2021, 3:08 PMsoedirgo
08/31/2021, 4:32 PMCrane
08/31/2021, 6:20 PMCrane
08/31/2021, 6:21 PMScott P
08/31/2021, 6:35 PM