diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0001_initial.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0001_initial.py index ad599ed0a..0d36348b6 100644 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0001_initial.py +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0001_initial.py @@ -1,6 +1,8 @@ -# Generated by Django 3.2.15 on 2022-08-15 13:33 +# Generated by Django 4.2.11 on 2024-04-17 14:10 +from django.conf import settings from django.db import migrations, models +import django.db.models.deletion class Migration(migrations.Migration): @@ -8,6 +10,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ @@ -19,10 +22,49 @@ class Migration(migrations.Migration): ('author', models.CharField(blank=True, help_text='The name of the author of the evaluation', max_length=255, null=True)), ('description', models.TextField(blank=True, help_text='A helpful description of what the evaluation is intended to do', null=True)), ('definition', models.JSONField(help_text='The raw json that will be sent as the instructions to the evaluation service')), - ('last_edited', models.DateTimeField(auto_now=True)), ], - options={ - 'unique_together': {('name', 'author', 'description')}, - }, + ), + migrations.CreateModel( + name='SpecificationTemplate', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('template_name', models.CharField(help_text='The name of the template', max_length=100, verbose_name='name')), + ('template_specification_type', models.CharField(choices=[('BackendSpecification', 'Backend'), ('FieldMappingSpecification', 'Field Mapping'), ('AssociatedField', 'Associated Field'), ('ValueSelector', 'Value Selector'), ('LocationSpecification', 'Location'), ('UnitDefinition', 'Unit Definition'), ('MetricSpecification', 'Metric'), ('SchemeSpecification', 'Scheme'), ('ThresholdDefinition', 'Threshold Definition'), ('ThresholdApplicationRules', 'Threshold Application Rules'), ('EvaluationSpecification', 'Evaluation'), ('CrosswalkSpecification', 'Crosswalk'), ('DataSourceSpecification', 'Data Source'), ('ThresholdSpecification', 'Threshold')], help_text='The type of specification that this template pertains to', max_length=50)), + ('template_configuration', models.JSONField(help_text='The configuration that should be applied to a given specification type')), + ('template_description', models.CharField(blank=True, help_text='A description of what the template does', max_length=500, null=True)), + ('template_last_modified', models.DateTimeField(auto_now=True, help_text='When this was last modified')), + ], + ), + migrations.CreateModel( + name='StoredDataset', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(help_text='An easy to reference name for the dataset', max_length=255)), + ('path', models.CharField(help_text='The path to the dataset', max_length=500)), + ('dataset_type', models.CharField(choices=[('geometry', 'Geometry')], help_text='The type of data the dataset provides', max_length=100)), + ('dataset_format', models.CharField(choices=[('gpkg', 'GeoPackage'), ('json', 'JSON'), ('geojson', 'GeoJSON')], help_text='The format of the dataset', max_length=100)), + ], + ), + migrations.AddConstraint( + model_name='storeddataset', + constraint=models.UniqueConstraint(fields=('dataset_type', 'name'), name='unique_stored_dataset'), + ), + migrations.AddField( + model_name='specificationtemplate', + name='author', + field=models.ForeignKey(help_text='The user who created this template', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='evaluationdefinition', + name='owner', + field=models.ForeignKey(blank=True, help_text='The user who owns the editing rights on this definition', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddConstraint( + model_name='specificationtemplate', + constraint=models.UniqueConstraint(fields=('template_name',), name='unique_template_idx'), + ), + migrations.AlterUniqueTogether( + name='evaluationdefinition', + unique_together={('name', 'owner')}, ), ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0002_storeddataset_storeddataset_unique_stored_dataset.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0002_storeddataset_storeddataset_unique_stored_dataset.py deleted file mode 100644 index 3757f5890..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0002_storeddataset_storeddataset_unique_stored_dataset.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 4.1.3 on 2022-12-21 14:02 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('evaluation_service', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='StoredDataset', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(help_text='An easy to reference name for the dataset', max_length=255)), - ('path', models.CharField(help_text='The path to the dataset', max_length=500)), - ('dataset_type', models.CharField(choices=[('geometry', 'Geometry')], help_text='The type of data the dataset provides', max_length=100)), - ('dataset_format', models.CharField(choices=[('gpkg', 'GeoPackage'), ('json', 'JSON'), ('geojson', 'GeoJSON')], help_text='The format of the dataset', max_length=100)), - ], - ), - migrations.AddConstraint( - model_name='storeddataset', - constraint=models.UniqueConstraint(fields=('dataset_type', 'name'), name='unique_stored_dataset'), - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0003_specificationtemplate_and_more.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0003_specificationtemplate_and_more.py deleted file mode 100644 index 759776c85..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0003_specificationtemplate_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 4.1.3 on 2023-03-24 20:27 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('evaluation_service', '0002_storeddataset_storeddataset_unique_stored_dataset'), - ] - - operations = [ - migrations.CreateModel( - name='SpecificationTemplate', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('template_name', models.CharField(help_text='The name of the template', max_length=100, verbose_name='name')), - ('template_specification_type', models.CharField(choices=[('BackendSpecification', 'Backend'), ('FieldMappingSpecification', 'Field Mapping'), ('AssociatedField', 'Associated Field'), ('ValueSelector', 'Value Selector'), ('LocationSpecification', 'Location'), ('UnitDefinition', 'Unit Definition'), ('MetricSpecification', 'Metric'), ('SchemeSpecification', 'Scheme'), ('ThresholdDefinition', 'Threshold Definition'), ('ThresholdApplicationRules', 'Threshold Application Rules'), ('EvaluationSpecification', 'Evaluation'), ('CrosswalkSpecification', 'Crosswalk'), ('DataSourceSpecification', 'Data Source'), ('ThresholdSpecification', 'Threshold')], help_text='The type of specification that this template pertains to', max_length=50)), - ('template_configuration', models.CharField(help_text='The configuration that should be applied to a given specification type', max_length=30000)), - ('template_description', models.CharField(blank=True, help_text='A description of what the template does', max_length=500, null=True)), - ('author', models.ForeignKey(help_text='The user who created this template', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.AddConstraint( - model_name='specificationtemplate', - constraint=models.UniqueConstraint(fields=('template_name', 'template_specification_type'), name='unique_template_idx'), - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0004_alter_specificationtemplate_template_configuration.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0004_alter_specificationtemplate_template_configuration.py deleted file mode 100644 index 8c66a3d0c..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0004_alter_specificationtemplate_template_configuration.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.1.3 on 2023-07-24 19:28 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('evaluation_service', '0003_specificationtemplate_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='specificationtemplate', - name='template_configuration', - field=models.JSONField(help_text='The configuration that should be applied to a given specification type'), - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0005_evaluationdefinition_owner.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0005_evaluationdefinition_owner.py deleted file mode 100644 index f14968064..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0005_evaluationdefinition_owner.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 4.1.3 on 2023-08-29 19:36 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('evaluation_service', '0004_alter_specificationtemplate_template_configuration'), - ] - - operations = [ - migrations.AddField( - model_name='evaluationdefinition', - name='owner', - field=models.ForeignKey(blank=True, help_text='The user who owns the editing rights on this definition', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0005_remove_specificationtemplate_unique_template_idx_and_more.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0005_remove_specificationtemplate_unique_template_idx_and_more.py deleted file mode 100644 index 4cb658fd5..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0005_remove_specificationtemplate_unique_template_idx_and_more.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 4.2.5 on 2023-10-26 21:23 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('evaluation_service', '0004_alter_specificationtemplate_template_configuration'), - ] - - operations = [ - migrations.RemoveConstraint( - model_name='specificationtemplate', - name='unique_template_idx', - ), - migrations.AddConstraint( - model_name='specificationtemplate', - constraint=models.UniqueConstraint(fields=('author', 'template_name', 'template_specification_type'), name='unique_template_idx'), - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0006_alter_evaluationdefinition_unique_together.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0006_alter_evaluationdefinition_unique_together.py deleted file mode 100644 index 026fb8a56..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0006_alter_evaluationdefinition_unique_together.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.1.3 on 2023-08-30 13:15 - -from django.conf import settings -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('evaluation_service', '0005_evaluationdefinition_owner'), - ] - - operations = [ - migrations.AlterUniqueTogether( - name='evaluationdefinition', - unique_together={('name', 'owner')}, - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0006_specificationtemplate_template_last_modified.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0006_specificationtemplate_template_last_modified.py deleted file mode 100644 index 35b203822..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0006_specificationtemplate_template_last_modified.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.5 on 2023-10-30 20:42 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('evaluation_service', '0005_remove_specificationtemplate_unique_template_idx_and_more'), - ] - - operations = [ - migrations.AddField( - model_name='specificationtemplate', - name='template_last_modified', - field=models.DateTimeField(auto_now=True, help_text='When this was last modified'), - ), - ] diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_auto_20230830_0825.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_auto_20230830_0825.py deleted file mode 100644 index 6a3ac11c3..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_auto_20230830_0825.py +++ /dev/null @@ -1,34 +0,0 @@ -# Generated by Django 4.1.3 on 2023-08-30 13:25 -import typing - -from django.db import migrations -from django.contrib.auth.models import User - - -def assign_owners_to_evaluation_definitions(apps, schema_editor): - EvaluationDefinition = apps.get_model("evaluation_service", "EvaluationDefinition") - - all_evaluation_definitions: typing.Sequence[EvaluationDefinition] = EvaluationDefinition.objects.all() - - for definition in all_evaluation_definitions: - possible_owners = User.objects.filter(username__icontains=definition.author) - - if possible_owners: - definition.owner = possible_owners.first() - else: - # Assign it to the first superuser so they can deal with it later - superusers = User.objects.filter(is_superuser=True) - if superusers: - definition.owner_id = superusers.first().id - definition.save() - - -class Migration(migrations.Migration): - - dependencies = [ - ('evaluation_service', '0006_alter_evaluationdefinition_unique_together'), - ] - - operations = [ - migrations.RunPython(assign_owners_to_evaluation_definitions) - ] 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 deleted file mode 100644 index 4739c6fc4..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0007_remove_specificationtemplate_unique_template_idx_and_more.py +++ /dev/null @@ -1,21 +0,0 @@ -# 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/migrations/0008_remove_evaluationdefinition_last_edited.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0008_remove_evaluationdefinition_last_edited.py deleted file mode 100644 index cb50af25d..000000000 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/migrations/0008_remove_evaluationdefinition_last_edited.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.1.3 on 2023-08-30 15:46 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('evaluation_service', '0007_auto_20230830_0825'), - ] - - operations = [ - migrations.RemoveField( - model_name='evaluationdefinition', - name='last_edited', - ), - ]