<-- Back

How to resolve "CRITICAL - M2EE: Error starting M2EE...ALTER TABLE "table" ADD CONSTRAINT "attribute/association" UNIQUE ("attribute/association")" startup errors

Introduction

After adding a unique database constraint on an entity with pre-existing records in the database, the next deployment fails with the following error in the logs:

CRITICAL - M2EE: Error starting M2EE...ALTER TABLE "table" ADD CONSTRAINT "attribute/association" UNIQUE ("attribute/association")

Environment

Applications hosted in any deployment type

Instructions/Procedure

When a uniqueness constraint is added to an entity which already contains data, all the existing objects for the affected entity are checked on deployment for the uniqueness of that attribute/association. If, for example, a uniqueness validation rule is applied to an insurance number, and there are multiple records with the same insurance number in the database, the deployment will fail. This is because the attribute/association is not unique, and therefore the validation rule cannot be fulfilled.

To resolve, while maintaining the unique validation rule, change or delete all but one (or all) of the entities containing duplicate attributes/associations. There can only be one, or zero, references of a unique attribute/association. Otherwise, remove the unique validation rule on the entity, as it is no longer unique.

Outcome

The error is resolved and the deployment will continue.

Internal information related

  • 286948

Additional information

Mendix documentation: Validation Rules // Existing Entities | Mendix Documentation 

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.