Logo-amall

My last deployment failed on my prod DB. I used hasura's built-in `updated_at` helper and I encountered this error: ``` {"level":"error","msg":"skipping applying migrations on database , encountered: { "code": "postgres-error", "error": "query execution failed", "internal": { "arguments": [], "error": { "description": null, "exec_status": "FatalError", "hint": null, "message": "must be owner of function set_current_timestamp_updated_at", "status_code": "42501" }, "prepared": false, "statement": "CREATE TABLE "public"."slacks" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "group_id" uuid NOT NULL, "url" text NOT NULL, "name" text NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("group_id") REFERENCES "public"."groups"("id") ON UPDATE cascade ON DELETE cascade);COMMENT ON TABLE "public"."slacks" IS E'Slack webhooks';\ CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()\ RETURNS TRIGGER AS $$\ DECLARE\ _new record;\ BEGIN\ _new := NEW;\ _new."updated_at" = NOW();\ RETURN _new;\ END;\ $$ LANGUAGE plpgsql;\ CREATE TRIGGER "set_public_slacks_updated_at"\ BEFORE UPDATE ON "public"."slacks"\ FOR EACH ROW\ EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();\ COMMENT ON TRIGGER "set_public_slacks_updated_at" ON "public"."slacks" \ IS 'trigger to set value of column "updated_at" to current timestamp on row update';\ CREATE EXTENSION IF NOT EXISTS pgcrypto;\ " }, "path": "$" }","time":"2022-11-11T09:56:22Z"} ```

Last active 4 months ago

11 replies

8 views

  • KR

    My last deployment failed on my prod DB. I used hasura's built-in updated_at helper and I encountered this error:

    {"level":"error","msg":"skipping applying migrations on database , encountered: 
    {
     "code": "postgres-error",
     "error": "query execution failed",
     "internal": {
     "arguments": [],
     "error": {
     "description": null,
     "exec_status": "FatalError",
     "hint": null,
     "message": "must be owner of function set_current_timestamp_updated_at",
     "status_code": "42501"
     },
     "prepared": false,
     "statement": "CREATE TABLE "public"."slacks" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "group_id" uuid NOT NULL, "url" text NOT NULL, "name" text NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("group_id") REFERENCES "public"."groups"("id") ON UPDATE cascade ON DELETE cascade);COMMENT ON TABLE "public"."slacks" IS E'Slack webhooks';\
    CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()\
    RETURNS TRIGGER AS $$\
    DECLARE\
     _new record;\
    BEGIN\
     _new := NEW;\
     _new."updated_at" = NOW();\
     RETURN _new;\
    END;\
    $$ LANGUAGE plpgsql;\
    CREATE TRIGGER "set_public_slacks_updated_at"\
    BEFORE UPDATE ON "public"."slacks"\
    FOR EACH ROW\
    EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();\
    COMMENT ON TRIGGER "set_public_slacks_updated_at" ON "public"."slacks" \
    IS 'trigger to set value of column "updated_at" to current timestamp on row update';\
    CREATE EXTENSION IF NOT EXISTS pgcrypto;\
    "
     },
     "path": "$"
    }","time":"2022-11-11T09:56:22Z"}
    
  • KR

    owner of set_current_timestamp_updated_at is nhost_admin
    not sure who runs the migrations during the deployments, maybe nhost_hasura ?

  • KR

    Any suggestions? @mention ?

  • NU

    @mention subdomain?

  • KR

    szxadoiptneqsvfwekaw

  • NU

    can you try again?

  • NU

    I fixed the ownership of that function

  • KR

    not right now, but thanks.
    I've checked and all functions created before the db migration is owned by nhostadmin - does it mean i won't be able to update them with future migrations? Do I need nhostadmin at all?

  • KR

    It's working now, but I fear I'll have the same problem in the future with any CREATE OR REPLACE FUNCTION... migrations. It seems my custom functions are owned by nhost_admin instead of nhost_hasura.

  • NU

    those functions are owned buy nhost_admin because of the migration step from RDS (new projects have the right owner everywhere). If you need to fix other functions, you can do that with the postgres role that you own:

    • alter function function-name owner to nhost_hasura;
  • KR

    Great, thanks

Last active 4 months ago

11 replies

8 views