Today I updated my Instance to 31.0.6 with a running psql17.4.
With the command “./occ upgrade” I got the message:
"Exception: Database error when running migration 5006Date20250527100000 for app analytics
An exception occurred while executing a query: SQLSTATE[42501]: Insufficient privilege: 7 ERROR: must be owner of table oc_analytics_threshold
Update failed
"
To solve this Issue I updated the owner of the database and all Tables from “nexcloud” User to the “oc_admin”.
psql -U nextcloud -h localhost
ALTER DATABASE nextcloud OWNER TO oc_admin;
GRANT ALL ON SCHEMA public TO oc_admin;
Update Owner for all Tables in the Database.
DO
$$
DECLARE
tbl RECORD;
BEGIN
-- Loop through each table in the specified schema
FOR tbl IN
SELECT tablename
FROM pg_catalog.pg_tables
WHERE schemaname = 'public' -- Replace 'public' with your schema name
LOOP
-- Alter the owner of each table
EXECUTE 'ALTER TABLE public.' || quote_ident(tbl.tablename) || ' OWNER TO oc_admin';
-- Replace 'public' with your schema and 'new_owner' with the new owner's name
END LOOP;
END;
$$;
after this i can run successfully the command ./occ upgrade