Hello
I was in the process of upgrading DSpace-CRIS from 2022.01.01 to
2023.02.05. We decided to migrate to another server instead of upgrading
the existing installation. I was following the migration guide here
<https://wiki.lyrasis.org/display/DSDOC7x/Migrating+DSpace+to+a+new+server>
and all went well until i ran './dspace database migrate' i got this error:
Migration exception:
java.sql.SQLException: Flyway migration error occurred
at
org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:766)
at
org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:651)
at
org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:646)
at
org.dspace.storage.rdbms.DatabaseUtils.main(DatabaseUtils.java:239)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at
org.dspace.app.launcher.ScriptLauncher.runOneCommand(ScriptLauncher.java:303)
at
org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:153)
at
org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:125)
at
org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:100)
Caused by:
org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration
V7.6_2024.04.23__alter_table_process_add_foreign_key_on_user_id.sql failed
------------------------------------------------------------------------------------
SQL State : 23503
Error Code : 0
Message : ERROR: insert or update on table "process" violates foreign
key constraint "user_id"
Detail: Key (user_id)=(517679f6-cbea-4519-b491-15886e069196) is not
present in table "eperson".
Location :
org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2024.04.23__alter_table_process_add_foreign_key_on_user_id.sql
(/opt/clean-sever/bin/file:/opt/clean-sever/lib/dspace-api-cris-2023.02.05.jar!/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2024.04.23__alter_table_process_add_foreign_key_on_user_id.sql)
Line : 17
Statement : -- Add the foreign key constraint with ON DELETE SET NULL
ALTER TABLE process ADD CONSTRAINT user_id FOREIGN KEY (user_id) REFERENCES
eperson (uuid) ON DELETE SET NULL
at
org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:385)
at
org.flywaydb.core.internal.command.DbMigrate.lambda$applyMigrations$1(DbMigrate.java:275)
at
org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:55)
at
org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:274)
at
org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:247)
at
org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:141)
at
org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:69)
at
org.flywaydb.core.internal.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:99)
at
org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:139)
at
org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:141)
at
org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:98)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:173)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:124)
at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:214)
at org.flywaydb.core.Flyway.migrate(Flyway.java:124)
at
org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:753)
... 11 more
Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException:
Migration
V7.6_2024.04.23__alter_table_process_add_foreign_key_on_user_id.sql failed
------------------------------------------------------------------------------------
SQL State : 23503
Error Code : 0
Message : ERROR: insert or update on table "process" violates foreign
key constraint "user_id"
Detail: Key (user_id)=(517679f6-cbea-4519-b491-15886e069196) is not
present in table "eperson".
Location :
org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2024.04.23__alter_table_process_add_foreign_key_on_user_id.sql
(/opt/clean-sever/bin/file:/opt/clean-sever/lib/dspace-api-cris-2023.02.05.jar!/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2024.04.23__alter_table_process_add_foreign_key_on_user_id.sql)
Line : 17
Statement : -- Add the foreign key constraint with ON DELETE SET NULL
ALTER TABLE process ADD CONSTRAINT user_id FOREIGN KEY (user_id) REFERENCES
eperson (uuid) ON DELETE SET NULL
at
org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.handleException(DefaultSqlScriptExecutor.java:275)
at
org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:222)
at
org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.execute(DefaultSqlScriptExecutor.java:126)
at
org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.executeOnce(SqlMigrationExecutor.java:69)
at
org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.lambda$execute$0(SqlMigrationExecutor.java:58)
at
org.flywaydb.core.internal.database.DefaultExecutionStrategy.execute(DefaultExecutionStrategy.java:27)
at
org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:57)
at
org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:377)
... 26 more
Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on
table "process" violates foreign key constraint "user_id"
Detail: Key (user_id)=(517679f6-cbea-4519-b491-15886e069196) is not
present in table "eperson".
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
at
org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:335)
at
org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:321)
at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:297)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:292)
at
org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)
at
org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)
at
org.flywaydb.core.internal.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:201)
at
org.flywaydb.core.internal.sqlscript.ParsedSqlStatement.execute(ParsedSqlStatement.java:95)
at
org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:210)
... 32 more
I looked at the .sql file and it appears the user_id value it's looking for
only exists once in the process table, which means (I'm guessing) it longer
exists in the eperson table. Not sure how that happened but when i tried
installing the old version on another server i didn't face this issue when
migrating. This error also appears in the logs when running 'oai import -c'
and it's causing the records to be shown as numbers (titles, authors,
description etc.) like i explain here
<https://groups.google.com/g/dspace-tech/c/GZJk2TXwLPo>
I ran out of ideas. Any help is appreciated
--
All messages to this mailing list should adhere to the Code of Conduct:
https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
---
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dspace-tech/8e2251bd-245d-48c2-bd88-342a02009505n%40googlegroups.com.