From 4a4603066994b11b806d5304008acbd3aa8eeb90 Mon Sep 17 00:00:00 2001 From: "christopher.tubbs" Date: Wed, 1 Nov 2023 15:30:06 -0500 Subject: [PATCH] Simplified the constraint for unique templates to only the template name since that is what templates are referenced by --- .../evaluation_service/commands/__init__.py | 6 ------ .../management/commands/__init__.py | 3 +++ ...ontemplate_unique_template_idx_and_more.py | 21 +++++++++++++++++++ .../evaluation_service/models.py | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) delete mode 100644 python/services/evaluationservice/dmod/evaluationservice/evaluation_service/commands/__init__.py create mode 100644 python/services/evaluationservice/dmod/evaluationservice/evaluation_service/management/commands/__init__.py create mode 100644 python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_remove_specificationtemplate_unique_template_idx_and_more.py diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/commands/__init__.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/commands/__init__.py deleted file mode 100644 index 980afecd4..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/commands/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -""" -@TODO: Put a module wide description here -""" -from __future__ import annotations - -import typing diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/management/commands/__init__.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/management/commands/__init__.py new file mode 100644 index 000000000..b417f681a --- /dev/null +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/management/commands/__init__.py @@ -0,0 +1,3 @@ +""" +Provides custom CLI commands for the evaluation service +""" diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_remove_specificationtemplate_unique_template_idx_and_more.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_remove_specificationtemplate_unique_template_idx_and_more.py new file mode 100644 index 000000000..4739c6fc4 --- /dev/null +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_remove_specificationtemplate_unique_template_idx_and_more.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.5 on 2023-11-01 20:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('evaluation_service', '0006_specificationtemplate_template_last_modified'), + ] + + operations = [ + migrations.RemoveConstraint( + model_name='specificationtemplate', + name='unique_template_idx', + ), + migrations.AddConstraint( + model_name='specificationtemplate', + constraint=models.UniqueConstraint(fields=('template_name',), name='unique_template_idx'), + ), + ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/models.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/models.py index 0a4b22e7f..f90c14a87 100644 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/models.py +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/models.py @@ -23,7 +23,7 @@ class SpecificationTemplate(models.Model): class Meta: constraints = [ - UniqueConstraint(name="unique_template_idx", fields=["author", "template_name", "template_specification_type"]) + UniqueConstraint(name="unique_template_idx", fields=["template_name"]) ] template_name = models.CharField(verbose_name="name", max_length=100, help_text="The name of the template")