Skip to content

Commit

Permalink
Merge pull request #24 from buildingSMART/feature/IVS-208_ModelInstan…
Browse files Browse the repository at this point in the history
…ce_unique_constraint

IVS-208 - Enforce unique constraint
  • Loading branch information
civilx64 authored Nov 12, 2024
2 parents f32164a + 1312041 commit 1738d92
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions migrations/0002_modelinstance_modelid_stepfileid_ifctype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.1.3 on 2024-11-11 22:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ifc_validation_models', '0001_initial'),
]

operations = [
migrations.AddConstraint(
model_name='modelinstance',
constraint=models.UniqueConstraint(fields=('model_id', 'stepfile_id', 'ifc_type'), name='modelid_stepfileid_ifctype'),
),
]
4 changes: 4 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ class Meta:
verbose_name = "Model Instance"
verbose_name_plural = "Model Instances"

constraints = [
models.UniqueConstraint(fields=['model_id', 'stepfile_id', 'ifc_type'], name='modelid_stepfileid_ifctype')
]

def __str__(self):

return f'#{self.id} - {self.ifc_type} - {self.model.file_name}'
Expand Down

0 comments on commit 1738d92

Please sign in to comment.