I'm getting `ERROR: must be member of role "supaba...
# help
x
I'm getting
ERROR: must be member of role "supabase_admin"
when trying to
supabase db push
to my production instance after having worked off a
dev
instance for the past day or so. Have been through the usual Google searches but all threads I've read are talking about the Supabase Studio SQL editor, not running commands locally. What do I have to do locally to be a member of the
supabase_admin
role?
n
Hello @xephyr! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
x
For added information, it looks to have applied 4 migrations successfully but the 5th has not been applied. Current assumption is that something in there has caused the error.
The migration that has not been applied:
Copy code
sql
-- 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.

CREATE TABLE IF NOT EXISTS public.user_avatars
(
    id uuid NOT NULL DEFAULT uuid_generate_v4(),
    created_at timestamp with time zone DEFAULT now(),
    user_id uuid NOT NULL,
    path text COLLATE pg_catalog."default",
    CONSTRAINT user_avatars_pkey PRIMARY KEY (id),
    CONSTRAINT user_avatars_user_id_fkey FOREIGN KEY (user_id)
        REFERENCES auth.users (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.user_avatars
    OWNER to supabase_admin;

ALTER TABLE IF EXISTS public.user_avatars
    ENABLE ROW LEVEL SECURITY;

GRANT ALL ON TABLE public.user_avatars TO anon;

GRANT ALL ON TABLE public.user_avatars TO postgres;

GRANT ALL ON TABLE public.user_avatars TO supabase_admin;

GRANT ALL ON TABLE public.user_avatars TO authenticated;

GRANT ALL ON TABLE public.user_avatars TO service_role;
CREATE POLICY "Enable DELETE for current user"
    ON public.user_avatars
    AS PERMISSIVE
    FOR DELETE
    TO public
    USING ((auth.uid() = user_id));
CREATE POLICY "Enable INSERT for current user"
    ON public.user_avatars
    AS PERMISSIVE
    FOR INSERT
    TO public
    WITH CHECK ((auth.uid() = user_id));
CREATE POLICY "Enable SELECT for all users"
    ON public.user_avatars
    AS PERMISSIVE
    FOR SELECT
    TO public
    USING (true);
CREATE POLICY "Enable UPDATE for current user"
    ON public.user_avatars
    AS PERMISSIVE
    FOR UPDATE
    TO public
    USING ((auth.uid() = user_id))
    WITH CHECK ((auth.uid() = user_id));

REVOKE ALL ON TABLE public.competitions FROM authenticated;
REVOKE ALL ON TABLE public.competitions FROM postgres;
REVOKE ALL ON TABLE public.competitions FROM service_role;
GRANT ALL ON TABLE public.competitions TO authenticated;

GRANT ALL ON TABLE public.competitions TO postgres;

GRANT ALL ON TABLE public.competitions TO service_role;

REVOKE ALL ON TABLE public.user_settings FROM authenticated;
REVOKE ALL ON TABLE public.user_settings FROM postgres;
REVOKE ALL ON TABLE public.user_settings FROM service_role;
GRANT ALL ON TABLE public.user_settings TO authenticated;

GRANT ALL ON TABLE public.user_settings TO postgres;

GRANT ALL ON TABLE public.user_settings TO service_role;
g
I'm not going to be much help, but I think the issue is that postgres role is likely what you are running this as and supabase_admin is slightly higher role. It may be as simple as the avatar grant is to supabase_admin and you don't have the"power" to do that. But likely need to elevate posgtres role to supabase_admin for your operation. There are several github threads on these types of issues. SORRY this is just a hint in case you don't get a better response....
n
xephyr (2022-04-29)
x
So
supabase db push
runs as
postgres
? I had assumed it would run as the user that I've logged in with via
supabase login
as I'm running it locally for now :/
An issue linked to the migration docs, which are for a psql run of a whole DB dump so a bit different, but I'll try manually running (in Studio SQL runner) step 4 before and step 7 after to see if that helps
Okay that worked. Thanks for the insight. Feels like the
supabase
cli stuff is still very WIP, lots of pain points at the moment 😬
Enjoying this overall though!
g
This postgres user versus supabase_admin is a problem with using database tools like datagrip also. Not sure what the long term solution is, but it is a dance at the moment.