Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 6.0.3 on 2026-03-26 15:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('questions', '0008_alter_genderresponse_value'),
]

operations = [
migrations.AlterField(
model_name='sexatbirthresponse',
name='value',
field=models.CharField(choices=[('F', 'Female'), ('M', 'Male')], max_length=1),
),
Comment on lines +13 to +17
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description/title is about allowing duplicate NHS numbers, but this migration also alters SexAtBirthResponse.value choices (removes the 'Intersex' option). If that change is intentional, it should be called out in the PR description and you should consider what happens to any existing rows with value 'I' (they will start failing model validation). If it’s not intentional, regenerate/split the migration so it only drops the unique constraint on User.nhs_number.

Copilot uses AI. Check for mistakes.
migrations.AlterField(
model_name='user',
name='nhs_number',
field=models.CharField(max_length=10),
),
]
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def create_user(self, sub, **extra_fields):

class User(AbstractBaseUser):
sub = models.CharField(max_length=255, unique=True)
nhs_number = models.CharField(max_length=10, unique=True)
nhs_number = models.CharField(max_length=10)
given_name = models.CharField(max_length=255)
family_name = models.CharField(max_length=255)
email = models.EmailField()
Expand Down
10 changes: 0 additions & 10 deletions lung_cancer_screening/questions/tests/unit/models/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ def test_is_invalid_without_nhs_number(self):
)


def test_raises_a_validation_error_if_nhs_number_is_duplicate(self):
with self.assertRaises(ValidationError) as context:
UserFactory(nhs_number=self.user.nhs_number)

self.assertIn(
"User with this Nhs number already exists.",
context.exception.messages
)


def test_nhs_number_has_a_max_length_of_10(self):
self.user.nhs_number = "1"*11

Expand Down
Loading