Skip to content

IAV-848/fix(AgentIntegration): add unique constraint on credentialInstanceUid column

salaheddine zidani a demandé de fusionner feature/IAV-848 vers develop

Summary

This MR enforces a column-level unique constraint on the credentialInstanceUid field in the AgentIntegration entity.

Problem

The agent_integrations table already declared a composite unique constraint via @UniqueConstraint(columnNames = {"agent_uid", "credential_instance_uid"}), but the credentialInstanceUid column itself was not individually marked as unique. This left a gap where different agents could theoretically hold the same credential instance UID, violating the expected 1-to-1 relationship between a credential instance and its deployment.

Changes

  • Added unique = true to the @Column annotation on credentialInstanceUid in AgentIntegration.java
// Before
@Column(name = "credential_instance_uid", nullable = false)
private String credentialInstanceUid;

// After
@Column(name = "credential_instance_uid", nullable = false, unique = true)
private String credentialInstanceUid;

Impact

  • A new unique index will be generated on the credential_instance_uid column by JPA/Hibernate
  • Prevents duplicate credential instance UIDs across different agent integrations at the database level
  • No behavioral change for existing valid data — only invalid duplicate entries are now blocked

Testing

  • Verify that attempting to persist two AgentIntegration records with the same credentialInstanceUid throws a DataIntegrityViolationException
  • Confirm migration generates the expected unique index on agent_integrations.credential_instance_uid

Related Issues

IAV-1045

Rapports de requête de fusion