-
Bug
-
Resolution: Answered
-
Low
-
None
-
3.3
-
None
Upgrading Confluence from 3.3 to 3.4.7 fails with:
2011-01-25 07:49:55,914 INFO [main] [springframework.web.context.ContextLoader] initWebApplicationContext Root WebApplicationContext: initialization completed in 21508 ms 2011-01-25 07:49:58,557 ERROR [main] [hibernate.tool.hbm2ddl.SchemaUpdate] execute Unsuccessful: alter table EXTRNLNKS add constraint FK97C10FE78DD41734 foreign key (CONTENTID) references CONTENT 2011-01-25 07:49:58,557 ERROR [main] [hibernate.tool.hbm2ddl.SchemaUpdate] execute ERROR: insert or update on table "extrnlnks" violates foreign key constraint "fk97c10fe78dd41734" Detail: Key (contentid)=(1213498) is not present in table "content". 2011-01-25 07:49:58,559 ERROR [main] [hibernate.tool.hbm2ddl.SchemaUpdate] execute could not complete schema update org.postgresql.util.PSQLException: ERROR: insert or update on table "extrnlnks" violates foreign key constraint "fk97c10fe78dd41734" Detail: Key (contentid)=(1213498) is not present in table "content". at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
Cause
The extrnlnks table contains stray/outdated entries that reference content in the content table that does not exist anymore.
Workaround
The example queries were run against a PostgreSQL database, please adjust them for your particular DBMS
- Ensure that you have a backup of the database!
- Identify the stray link entries, (there should only be a few entires that point to non-existing content):
SELECT e.linkid, e.contentid, c.contentid, e.url FROM extrnlnks as e LEFT OUTER JOIN content as c ON e.contentid = c.contentid WHERE c.contentid IS NULL
- Delete the link stray entries
DELETE FROM extrnlnks WHERE linkid IN (SELECT e.linkid FROM extrnlnks as e LEFT OUTER JOIN content as c ON e.contentid = c.contentid WHERE c.contentid IS NULL)
- Restart Confluence to carry on with the upgrade.