geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
406 stars 482 forks source link

Update from 3.10.8 to 4.10.6 fails, Settings.editable column doesn't exist in GN 4 #6054

Open juanluisrp opened 2 years ago

juanluisrp commented 2 years ago

Describe the bug

Using a 3.10.8 database and trying to start GN 4.0.6-SNAPSHOT throws an error while executing the migration scripts. Error is

2021-11-23 11:52:24,642 INFO  [geonetwork.databasemigration] -          - SQL migration WEB-INF/classes/setup/sql/migrate/v3110 prefix:migrate- ...
2021-11-23 11:52:24,670 INFO  [geonetwork.databasemigration] -           Errors occurs during SQL migration file: ERROR: column "editable" of relation "settings" does not exist
  Position: 22
2021-11-23 11:52:24,670 ERROR [geonetwork.databasemigration] - ERROR: column "editable" of relation "settings" does not exist
  Position: 22
org.postgresql.util.PSQLException: ERROR: column "editable" of relation "settings" does not exist
  Position: 22
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
    at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
    at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266)
    at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
    at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
    at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
    at org.fao.geonet.lib.DbLib.runSQL(DbLib.java:166)
    at org.fao.geonet.lib.DbLib.insertData(DbLib.java:88)
    at org.fao.geonet.DatabaseMigration.doMigration(DatabaseMigration.java:228)
    at org.fao.geonet.DatabaseMigration.migrateDatabase(DatabaseMigration.java:148)
    at org.fao.geonet.DatabaseMigration.postProcessAfterInitialization(DatabaseMigration.java:120)

To Reproduce

Steps to reproduce the behavior:

  1. Populate a database with a dump of GN 3.10.8 database.
  2. Start GN 4.0.6-SNAPSHOT using that database

Expected behavior The migration process should finish successfully.

Additional info It looks like this PR (https://github.com/geonetwork/core-geonetwork/pull/5565) has not been added to main branch and the Settings table doesn't have an editable column in that version.

landryb commented 1 year ago

regarding #5565 i dont know if the hibernate code/jpa stuff is supposed to add new columns, but i've also encountered this issue migrating from 3.8.2 to 4.0.6.

I ended up manually creating it so that the migration step did some progress:

[db3:5432] geonetwork@geonetwork=> ALTER TABLE Settings ADD COLUMN editable VARCHAR(1) DEFAULT 'y';
ALTER TABLE

but then it failed on other cryptic issues in v3110/UpdateMetadataStatus.java , i'm looking at #6055 & #6058.