ERROR: permission denied for relation flyway_schema_history

Dear Expert and Community

i upgraded from 2.30 to 2.31.7 and im getting a flyway error (See attached doc of catalina log output. I restored a db dump made from a 2.31.4 instance into an empty db, however when i fire up the instance i get the error. Kindly help.

Appreciated
flyway error.docx (17.4 KB)

@Yashiindi

I have been battling with various upgrade errors recently when trying to upgrade from 2.30 to 2.31.7, so that upgrade path can be tricky. I have found workarounds for those problems, though (one of those bugs is described in JIRA 8151)

Your error log looks very similar to the log errors from a failed upgrade we had just an hour ago, but it was caused by Infra erroneously trying to install 2.33.1 onto an instance running 2.33 dev (i.e. a “downgrade”), and changing that to using 2.33 dev latest build fixed that.

Can you verify that you dropped sql views before attempting the update?

If you are sure about that, then I would firstly roll back to 2.30 (latest build) and make sure everything start up and work correctly.

I think one main problem is this found in your log:
"Error while retrieving the list of applied migrations from Schema History table “public”.“flyway_schema_history”

That table do not exist in 2.30 (and should not exist!), it is initially created when you run the 2.31.x upgrade with a version 1 “BASELINE” record, and then each flyway schema update step is recorded a one record. This is how it looks after I managed to bypass the upgrade bugs/problems in the SL HMIS instance (first 4 columns):

1 “1” “<< Flyway Baseline >>” “BASELINE”
2 “2.30.0” “Populate dhis2 schema if empty database” “JDBC”
3 “2.31.1” “Migrations for release v31” “SQL”
4 “2.31.2” “Job configuration param to jsonb” “JDBC”
5 “2.31.3” “Program notification template to templateid” “JDBC”
6 “2.31.4” “Add defaults for validationstrategy” “JDBC”
7 “2.31.5” “Add new user role for new capture app” “JDBC”
8 “2.31.6” “Update default program access level to OPEN” “SQL”
9 “2.31.7” “Delete code klass unique constraint in deleted object” “SQL”
10 “2.31.8” “Program rule variable option code” “SQL”
11 “2.31.9” “Add user permissions for new data viz app” “JDBC”
12 “2.31.10” “Remove storagestatus column from fileresource table” “SQL”
13 “2.31.11” “Copy timestamp value into lastupdated field” “SQL”
14 “2.31.12” “Assign Job Configuration UID” “SQL”
15 “2.31.13” “Create categories categoryoptions index” “SQL”
16 “2.31.14” “Add translations for dataSet section” “SQL”
17 “2.31.15” “RemoveOrphanProgramStageInstances” “SQL”
18 “2.31.16” “Remove unused columns from attribute values” “SQL”
19 “2.31.17” “Clean attribute values” “SQL”
20 “2.31.18” “Set embedded expressions nullable and unique” “SQL”
21 “2.31.19” “Convert push analysis job parameters into list of string” “JDBC”

So you can see the system would record each of the flyway steps.

I don’t really understand what you mean by “I restored a db dump made from a 2.31.4 instance” in this context…

Hope this helps

Regards
Calle