From 8edd50e3b8459b08d0322a78c2ce52c9d396d3e8 Mon Sep 17 00:00:00 2001 From: Christophe Henry Date: Mon, 10 Jan 2022 14:39:41 +0100 Subject: [PATCH] Fix tests --- .../migrations/0050_auto_20210321_2154.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aidants_connect_web/migrations/0050_auto_20210321_2154.py b/aidants_connect_web/migrations/0050_auto_20210321_2154.py index 9e80a1353..f84b2059c 100644 --- a/aidants_connect_web/migrations/0050_auto_20210321_2154.py +++ b/aidants_connect_web/migrations/0050_auto_20210321_2154.py @@ -1,3 +1,4 @@ +# flake8: noqa from django.db import migrations from aidants_connect.constants import RequestOriginConstants @@ -6,7 +7,7 @@ def add_organisation_types(apps, schema_editor): OrganisationType = apps.get_model("aidants_connect_web", "OrganisationType") for type in RequestOriginConstants: - OrganisationType.objects.get_or_create(pk=type.value, name=type.label) + OrganisationType.objects.get_or_create(id=type.value, name=type.label) class Migration(migrations.Migration): @@ -17,4 +18,10 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(add_organisation_types), + # Resets the starting value for AutoField + # See https://docs.djangoproject.com/en/dev/ref/databases/#manually-specified-autoincrement-pk + migrations.RunSQL( + """SELECT setval(pg_get_serial_sequence('"aidants_connect_web_organisationtype"','id'), coalesce(max("id"), 1), max("id") IS NOT null) + FROM "aidants_connect_web_organisationtype";""" + ), ]