Getting a 'Duplicate key or integrity constraint violation' During XML Import
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Symptoms
When migrating to MySQL from another database, such as HSQL, importing the site backup often fails with an error like this:
Duplicate key or integrity constraint violation message from server
Cause
Such errors occur because usually MySQL evaluates unique key constraints and primary key constraints in a case insensitive way. So if you have a space with the key "sp" and another with the key "SP", MySQL will refuse to add the second one.
Resolution
This problem is avoidable by setting the collation on the database to be case sensitive.