IAV-848/fix(AgentIntegration): add unique constraint on credentialInstanceUid column
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 = trueto the@Columnannotation oncredentialInstanceUidinAgentIntegration.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_uidcolumn 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 AgentIntegrationrecords with the samecredentialInstanceUidthrows aDataIntegrityViolationException -
Confirm migration generates the expected unique index on agent_integrations.credential_instance_uid