Boni
04/02/2022, 1:35 AMcreate sequence factura_id_seq;
2. Update sequence start ALTER SEQUENCE <your_sequence_name> RESTART WITH <max_id_in_table + 1>
3. Update the table ALTER TABLE factura ALTER id SET DEFAULT NEXTVAL('factura_id_seq');
I'm not sure if this is the best way to solve it but if you have any other suggestions i'm happy to hear them thankspcj127
04/03/2022, 10:06 PMnewstr := fmt.Sprintf("%s-%s", "foo", "bar")
This has been surprisingly difficult to google.norman
04/05/2022, 4:32 AMpostgres=> CREATE TYPE public.service_type AS ENUM ('workout', 'recovery');
ERROR: permission denied for table _field
CONTEXT: SQL statement "truncate table graphql._field"
PL/pgSQL function graphql.rebuild_schema() line 3 at SQL statement
SQL statement "SELECT graphql.rebuild_schema()"
PL/pgSQL function graphql.rebuild_on_ddl() line 31 at PERFORM
postgres=>
dmytro.eth
04/05/2022, 9:15 AMcountries
where each country
has a people
array of uuid. Every county
can have multiple cities
where each city
has one county_id
. I want to giver CRUD access to cities
for the people
.
How can I set it up using the RLS?
UPD: Added a SQL diagram in the thread.dmytro.eth
04/05/2022, 9:32 AMdigitalsimboja
04/07/2022, 5:03 AMschema.grapghql
from my Supabase Tables. Is there any command I can run to automatically generate the schema?fernandolguevara
04/07/2022, 11:44 AMselect graphql.rebuild_schema();
?digitalsimboja
04/07/2022, 11:46 AMfernandolguevara
04/07/2022, 12:01 PMselect * from graphql.type;
in this view is the compiled schema, perhaps u can use that info to build the schema yourselfdigitalsimboja
04/07/2022, 12:06 PMyarn codegen:fetch
as the closest call to fetch the schema from the Supabase table following this: https://github.com/supabase-community/supabase-graphql-examplefernandolguevara
04/07/2022, 12:09 PMfernandolguevara
04/07/2022, 12:10 PMpackage.json
"codegen:fetch": "node --no-warnings scripts/fetchGraphQLSchema ",
fernandolguevara
04/07/2022, 12:25 PMfernandolguevara
04/07/2022, 12:26 PMjs
console.log(JSON.stringify({
query: getIntrospectionQuery(),
}), null, ' ');
fernandolguevara
04/07/2022, 12:27 PMpgsql
select graphql.resolve($$
<query>
$$);
digitalsimboja
04/08/2022, 1:20 PMdigitalsimboja
04/08/2022, 1:20 PMsilentworks
04/08/2022, 1:26 PMsilentworks
04/08/2022, 1:54 PMMuezz
04/08/2022, 8:09 PMdart
create or replace function calculate_current_balance(acc_name text)
returns numeric as $$
declare
debit_total numeric;
credit_total numeric;
begin
select SUM(amount)
into debit_total
from transactions
where transactions."debitAccount" = acc_name;
select SUM(amount)
into credit_total
from transactions
where transactions."creditAccount" = acc_name;
if debit_total=null
then
debit_total=0;
end if;
if credit_total=null
then
credit_total=0;
end if;
return credit_total-debit_total;
end;
$$ language plpgsql
When there is no row containing the acc_name
in any one of the two queries, it returns null
. To get rid of that, I added these if statements but I am still getting null
. Any idea how I can fix this?garyaustin
04/08/2022, 8:41 PMmagicbyt3
04/09/2022, 10:29 AMsql
UPDATE TABLE_A
SET col_a = CASE WHEN col_a + val_a < 11
THEN col_a + val_a
ELSE col_a END
WHERE userid = auth.uid();
IF FOUND THEN
UPDATE TABLE_B
SET col_b = col_b - val_b
WHERE id = auth.uid();
END IF;
TABLE_A is updated only if col_a + val_a < 11 however TABLE_B always gets updated and I only want to update it if TABLE_A has been updated first. How would I do that?
Thanks in advancetourdownunder
04/10/2022, 12:20 AMbaptisteArno
04/10/2022, 6:36 PMSELECT u.id FROM "User" u
JOIN "Typebot" t ON u.id = t."ownerId"
WHERE (SELECT count(*) FROM "Result" r WHERE r."typebotId" = t.id) >= 30
Result table has 66,000 records. I'm wondering, is there a way to optimize this?tourdownunder
04/11/2022, 2:00 AMAghilan
04/11/2022, 2:47 AMsql
begin
insert into public.UserFinanceData(id)
values(new.id);
return new;
end;
Aghilan
04/11/2022, 2:48 AMAghilan
04/11/2022, 2:49 AMDevyn
04/14/2022, 2:30 AMbegin
if (old.raw_user_meta_data != new.raw_user_meta_data) then
update public.profiles
set username = new.raw_user_meta_data ->> 'username'
where id = new.id;
end if;
return new;
end;
And here is my simple auth.update function: **const** { user, error } = await auth.update({ data: { username: username } });
For some reason, this results in an error. I know it has to be something with the trigger/function, because the update is successful without it. Any ideas?garyaustin
04/14/2022, 2:51 AM