Migration from HSQLDB to postgresql fails
Asked by HN:

I ran crucible data migration from the browser, but the following message was output and it was not possible to migrate.  
Could you tell us about the cause?

Environment  
OS?Ubuntu 18.04.1 LTS  
DataBase?PostgreSQL 9.6  
Fisheye/Crucible?4.5.3

```
LOG
fisheye.out?
2018-11-16 10:40:59,348 ERROR - Database migration failed: com.cenqua.crucible.hibernate.CruDBException: Problem with constraints script /home/crucible/fecru-4.5.3/sql/POSTGRESQL/schema/constraints_106.sql
com.cenqua.crucible.hibernate.CruDBException: Problem with constraints script /home/crucible/fecru-4.5.3/sql/POSTGRESQL/schema/constraints_106.sql
at com.cenqua.crucible.hibernate.DefaultDBControl.addConstraints(DefaultDBControl.java:377) [fisheye.jar:?]
at com.atlassian.crucible.migration.item.DBImporter.importData(DBImporter.java:145) [fisheye.jar:?]
at com.atlassian.crucible.actions.admin.database.DBEditHelper$ImportRunner.call(DBEditHelper.java:91) [fisheye.jar:?]
at com.atlassian.crucible.actions.admin.database.DBEditHelper$ImportRunner.call(DBEditHelper.java:73) [fisheye.jar:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_171]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_171]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
Caused by: com.cenqua.crucible.hibernate.CruDBException: SQL script error on line 14: "alter table cru_feindex_msg add constraint FKB56857DC665511F3 foreign key (cru_fr_id) references cru_re
vision;"
(ERROR: insert or update on table "cru_feindex_msg" violates foreign key constraint "fkb56857dc665511f3"
Detail: Key (cru_fr_id)=(1069) is not present in table "cru_revision".), please contact http://www.atlassian.com/support/
at com.cenqua.crucible.hibernate.DefaultDBControl.executeScript(DefaultDBControl.java:593) [fisheye.jar:?]
at com.cenqua.crucible.hibernate.DefaultDBControl.executeScript(DefaultDBControl.java:524) [fisheye.jar:?]
at com.cenqua.crucible.hibernate.DefaultDBControl.addConstraints(DefaultDBControl.java:371) [fisheye.jar:?]
... 9 more
Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on table "cru_feindex_msg" violates foreign key constraint "fkb56857dc665511f3"
Detail: Key (cru_fr_id)=(1069) is not present in table "cru_revision".
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161) [postgresql-9.3-1101-jdbc4.jar:?]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890) [postgresql-9.3-1101-jdbc4.jar:?]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) [postgresql-9.3-1101-jdbc4.jar:?]
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559) [postgresql-9.3-1101-jdbc4.jar:?]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:403) [postgresql-9.3-1101-jdbc4.jar:?]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:331) [postgresql-9.3-1101-jdbc4.jar:?]
at com.cenqua.crucible.hibernate.DefaultDBControl.executeScript(DefaultDBControl.java:565) [fisheye.jar:?]
... 11 more
```

browser message?

```

Started
Starting ActiveObjects backup...
* Backing up Database Information
* Backing up Table Definitions
** Table count: 5
* Backing up Tables
** Backing up 'AO_2913F5_COMMENT_ISSUE'
** Backing up 'AO_38321B_CUSTOM_CONTENT_LINK'
** Backing up 'AO_8219D4_COMMIT_HOOK_CONFIG'
** Backing up 'AO_A0B856_WEB_HOOK_LISTENER_AO'
** Backing up 'AO_B434B9_WEB_HOOK'
ActiveObjects backup completed!
Creating table definitions...
0 rows written, 1 tables completed.
1 rows written, 1 tables completed.
2 rows written, 2 tables completed.
39 rows written, 4 tables completed.
39 rows written, 5 tables completed.
40 rows written, 5 tables completed.
1454 rows written, 7 tables completed.
1455 rows written, 7 tables completed.
3050 rows written, 8 tables completed.
3077 rows written, 9 tables completed.
7778 rows written, 10 tables completed.
7779 rows written, 10 tables completed.
12731 rows written, 11 tables completed.
12732 rows written, 11 tables completed.
12748 rows written, 12 tables completed.
12813 rows written, 13 tables completed.
13713 rows written, 14 tables completed.
13714 rows written, 15 tables completed.
17314 rows written, 16 tables completed.
32313 rows written, 16 tables completed.
40410 rows written, 17 tables completed.
40410 rows written, 19 tables completed.
40410 rows written, 20 tables completed.
40411 rows written, 20 tables completed.
40475 rows written, 21 tables completed.
40486 rows written, 23 tables completed.
40487 rows written, 23 tables completed.
40498 rows written, 25 tables completed.
40499 rows written, 25 tables completed.
40504 rows written, 26 tables completed.
44861 rows written, 28 tables completed.
44862 rows written, 28 tables completed.
55490 rows written, 29 tables completed.
55707 rows written, 30 tables completed.
56004 rows written, 32 tables completed.
56004 rows written, 33 tables completed.
56005 rows written, 33 tables completed.
56044 rows written, 34 tables completed.
56053 rows written, 35 tables completed.
56068 rows written, 37 tables completed.
56069 rows written, 37 tables completed.
56218 rows written, 38 tables completed.
56218 rows written, 40 tables completed.
56218 rows written, 41 tables completed.
56219 rows written, 41 tables completed.
56220 rows written, 42 tables completed.
56220 rows written, 44 tables completed.
56221 rows written, 44 tables completed.
56237 rows written, 45 tables completed.
56238 rows written, 46 tables completed.
56782 rows written, 47 tables completed.
57079 rows written, 49 tables completed.
57080 rows written, 49 tables completed.
57109 rows written, 51 tables completed.
57110 rows written, 51 tables completed.
64637 rows written, 52 tables completed.
89469 rows written, 52 tables completed.
106183 rows written, 52 tables completed.
122109 rows written, 53 tables completed.
122109 rows written, 54 tables completed.
122109 rows written, 55 tables completed.
122110 rows written, 55 tables completed.
122621 rows written, 56 tables completed.
122633 rows written, 57 tables completed.
123934 rows written, 58 tables completed.
123937 rows written, 59 tables completed.
124087 rows written, 61 tables completed.
124088 rows written, 61 tables completed.
124115 rows written, 63 tables completed.
124116 rows written, 63 tables completed.
134115 rows written, 63 tables completed.
135144 rows written, 65 tables completed.
135144 rows written, 66 tables completed.
135144 rows written, 67 tables completed.
135145 rows written, 67 tables completed.
135174 rows written, 68 tables completed.
135176 rows written, 69 tables completed.
139798 rows written, 70 tables completed.
140048 rows written, 72 tables completed.
140048 rows written, 73 tables completed.
140049 rows written, 73 tables completed.
140052 rows written, 75 tables completed.
140052 rows written, 76 tables completed.
140052 rows written, 77 tables completed.
140052 rows written, 78 tables completed.
140053 rows written, 78 tables completed.
140054 rows written, 80 tables completed.
140055 rows written, 80 tables completed.
Adding database constraints...
Problem with constraints script /home/crucible/fecru-4.5.3/sql/POSTGRESQL/schema/constraints_106.sql
Database migration failed: com.cenqua.crucible.hibernate.CruDBException: Problem with constraints script /home/crucible/fecru-4.5.3/sql/POSTGRESQL/schema/constraints_106.sql
```


Answers:
author: Felipe Kraemer
body: Hi [@HN](/t5/user/viewprofilepage/user-id/2313467),

This error usually suggests an HSQL database corruption issue that is not allowing the migration scripts to finish successfully. We're wondering if the article below can help resolving this issue:

[Migrating from HSQLDB to any database fails](https://confluence.atlassian.com/fishkb/migrating-from-hsqldb-to-any-database-fails-317195386.html)

Please make sure to backup your instance just to be on the safe side before running that script.

Regards,

Felipe

comments: author: HN
body: Thank you for your reply.  
I solved it with the means presented.  
Thank you very much.