JustinT
11/07/2022, 5:11 AMSQL
CREATE POLICY "asf i5g8hi_1"
ON storage.objects FOR
SELECT TO public USING
(((bucket_id = 'results'::text) AND ((storage.foldername(name))[1] = 'results'::text)
AND (
((current_setting('request.headers'::text, true))::json ->> 'blah'::text) = 'bleep'
)
) );
with some Python
python
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_ANON_KEY")
supabase: Client = create_client(
url, key, ClientOptions(headers={"blah": "bleep"}))
storage = supabase.storage()
buckets = storage.list_buckets()
results = storage.get_bucket("results")
but i am having trouble testing/debugging this.
Is there anyway to view the auth checking logs? Or to debug this at all?Anurag
11/07/2022, 5:34 AMHege
11/07/2022, 5:45 AMjake.nz
11/07/2022, 6:23 AMFirebat
11/07/2022, 7:03 AMfattenap
11/07/2022, 7:34 AMnako
11/07/2022, 8:14 AMPlayWolf
11/07/2022, 10:15 AMixxie
11/07/2022, 11:23 AMchrismasters
11/07/2022, 11:35 AMsupabase db reset
everything works as expected.
The problem occurs when trying to push these changes to my production database.
I get this error when running supabase db push
Error: ERROR: must be owner of table streams (SQLSTATE 42501); while executing migration 20221106184147
The debug message doesn't offer much more information
2022/11/07 12:33:31 PG Recv: {"Type":"ErrorResponse","Severity":"ERROR","SeverityUnlocalized":"ERROR","Code":"42501","Message":"must be owner of table streams","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"aclchk.c","Line":3583,"Routine":"aclcheck_error","UnknownFields":null}
Has anyone experienced this? Would appreciate any advice to resolve. Thanks!alx90
11/07/2022, 12:26 PMerock
11/07/2022, 1:02 PMsudo42
11/07/2022, 1:58 PMdan_v
11/07/2022, 3:26 PMuser_id
where I'm saving the uid, and I'm trying to create the following policy.
CREATE POLICY "Enable select for users based on user_id" ON "public"."user-trips"
AS PERMISSIVE FOR SELECT
TO public
USING (auth.uid() = user_id)
However when calling supabase.from("user-trips").select("*");
I'm simply getting an empty array.
Any ideas what I'm doing wrong?kingpeppe
11/07/2022, 3:53 PMtokens.data
gives me an error
> (property) data: (Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any)["Tables"]["tokens"]["Row"][] | null
> Object is possibly 'null'.deno-ts(2531)
supabase.ts
ts
export const getTokens = async () => {
return await supabase.from('tokens').select('*')
}
// TYPES
type TokensResponse = Awaited<ReturnType<typeof getTokens>>
export type TokensResponseSuccess = TokensResponse['data']
export type TokensResponseError = TokensResponse['error']
main.ts
ts
const tokens = await getTokens()
const ids = tokens.data.map(token => token.coingecko_id).filter(id => id != null)
What am I doing wrong?kingpeppe
11/07/2022, 4:23 PMgetTokenIds()
?
ts
export const getTokens = async () => {
return await supabase.from('tokens').select('*')
}
export const getTokenIds = tokens => {
return tokens.data!.map(token => token.coingecko_id).filter(id => id != null)
}
getTokens()
returns
ts
{
error: null,
data: [{some data}, {some data}]
}
would be used in this context
ts
const tokens = await getTokens()
const ids = getTokenIds(tokens)
sixfour
11/07/2022, 5:44 PMgesusc
11/07/2022, 6:01 PMdrocha
11/07/2022, 6:29 PMsupabase db remote commit
.
It generate a new migration, and when I try to run it supabase db reset
I receive this error
txt
Error: ERROR: role "postgres_temporary_object_holder" does not exist (SQLSTATE 42704)
Then I stop supabase, and now I can't even start it, with supabase start
txt
supabase start
Applying migration 20221029194050_remote_commit.sql...
Applying migration 20221107171735_remote_commit.sql...
Error: ERROR: role "postgres_temporary_object_holder" does not exist (SQLSTATE 42704)
At statement 0: -- This script was generated by the Schema Diff utility in pgAdmin 4
-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
-- and may require manual changes to the script to ensure changes are applied in the correct order.
-- Please report an issue for any failure with the reproduction steps.
ALTER FUNCTION public.handle_new_user()
OWNER TO postgres_temporary_object_holder;
Did I did something wrong? I could not understand the steps of applying this migration.jimmie
11/07/2022, 7:31 PMAskar
11/07/2022, 7:47 PMgetUserList
, do they still count as an active user? What is also considered an edge function invocation
?ZaDeR47
11/07/2022, 7:54 PMseed.sql
that gets run when I call npx supabase start
- anyone know?ZaDeR47
11/07/2022, 8:07 PMts
// given `const userId: string = '';`
supaClient.channel(`public:user_profiles:user_id=eq.${userId}`)
.on(
"postgres_changes",
{
event: "*",
schema: "public",
table: "user_profiles",
filter: `user_id=eq.${userId}`, // <== here?
},
(payload) => {
setUserInfo({ ...userInfo, profile: payload.new as UserProfile });
}
)
.subscribe();
config_wizard
11/07/2022, 8:12 PM{ //type customer:
"id": 1,
"description": "hello world",
"friends": [
{
"id": 3,
"name": "james bond"
}
]
}
I have a table holding all the top level objects, a table holding the friend and a table called friends_connections
which holds the many2many relationships, i.e ID -> ID.
Using the javascript supabase library I am think I can do rpc("update_contacts", jsonObj)
but I'm not sure what I would put in the function? I think I could do it by literally updating each part one by one and perhaps pass the friends
as another argument rather than as a child, but I feel there is an atomic way I should be doing this where PSQL is clever enough to rollback the whole thing if something fails. A link of simple example of updating the customer
and the relations to friends
using the friends_connections
table would be really helpful. Thank you!Fainaru
11/07/2022, 9:10 PMgtims123
11/07/2022, 10:19 PMlewisd
11/07/2022, 10:37 PMcreate table "userWantList" (
userId uuid references "userData" (id) primary key,
"createdAt" timestamp default now(),
"collectibleId" character not null primary key,
"collectibleType" bigint references "collectibleTypes" (id)
);
Gives me the error multiple primary keys for table "userWantList" are not allowed
Berteotti
11/07/2022, 11:02 PMjkb5801
11/07/2022, 11:27 PMwolf5
11/07/2022, 11:53 PMfetch("https://your-url-supabase.co/rest/v1/user?id=eq.1&select=*")
What are the syntax for queries of count, range, etc?