Common database issues

10.9.0: Duplicate definition field names on definitions

When migrating to Ucommerce Next Gen >10.9.0, you might encounter the following error:

Ucommerce database migration failed with message The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.uCommerce_DefinitionField' and the index name 'UX_uCommerce_DefinitionField_DefinitionId_Name'. The duplicate key value is (1, Organization). The statement has been terminated., in script 117 - Create missing unique indexes on definition fields

This means that you have multiple definition fields with the same name for the same definition. This makes the data ambiguous and should be avoided. Unfortunately, we cannot know what data is correct and apply automatic corrections. Instead, what you have to do is clean up the database manually before proceeding with the migration.

Fortunately we have made this task easy for you. To find the duplicates that needs to be cleaned up, run the following scripts:

Product definitions
SELECT pdf.* FROM uCommerce_ProductDefinitionField as pdf 
INNER JOIN ( 
    SELECT [ProductDefinitionId], [Name] 
    FROM [uCommerce_ProductDefinitionField] 
    GROUP BY ProductDefinitionId, Name 
    HAVING COUNT(*) > 1 
) AS Duplicates ON pdf.ProductDefinitionId = Duplicates.ProductDefinitionId AND pdf.Name = Duplicates.Name
ORDER BY Name, ProductDefinitionId
Other definitions
SELECT df.* FROM uCommerce_DefinitionField as df 
INNER JOIN ( 
    SELECT [DefinitionId], [Name] 
    FROM [uCommerce_DefinitionField] 
    GROUP BY DefinitionId, Name 
    HAVING COUNT(*) > 1 
) AS Duplicates ON df.DefinitionId = Duplicates.DefinitionId AND df.Name = Duplicates.Name
ORDER BY Name, DefinitionId

Last updated