InstanceLink unique constraint source and target

Prevent creating InstanceLinks with duplicate
source and target pairings.

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster
2024-01-31 15:59:44 -05:00
committed by Seth Foster
parent eeae1d59d4
commit 21fd6af0f9
2 changed files with 14 additions and 0 deletions

View File

@@ -141,4 +141,10 @@ class Migration(migrations.Migration):
help_text='The target receptor address of this peer link.', on_delete=django.db.models.deletion.CASCADE, to='main.receptoraddress'
),
),
migrations.AddConstraint(
model_name='instancelink',
constraint=models.UniqueConstraint(
fields=('source', 'target'), name='unique_source_target', violation_error_message='Field source and target must be unique together.'
),
),
]