Improved migration, still fails if email duplicates exist in current DB

This commit is contained in:
eeintech 2020-10-13 07:43:57 -05:00
parent ac82640c6c
commit 70a3b7f891

View File

@ -16,12 +16,21 @@ class Migration(migrations.Migration):
] ]
operations = [ operations = [
# Allow email field to be NULL
migrations.AlterField(
model_name='company',
name='email',
field=models.EmailField(blank=True, help_text='Contact email address', max_length=254, null=True, unique=False, verbose_name='Email'),
),
# Convert empty email string to NULL
migrations.RunPython(make_empty_email_field_null), migrations.RunPython(make_empty_email_field_null),
# Make email field unique
migrations.AlterField( migrations.AlterField(
model_name='company', model_name='company',
name='email', name='email',
field=models.EmailField(blank=True, help_text='Contact email address', max_length=254, null=True, unique=True, verbose_name='Email'), field=models.EmailField(blank=True, help_text='Contact email address', max_length=254, null=True, unique=True, verbose_name='Email'),
), ),
# Remove unique constraint on name field
migrations.AlterField( migrations.AlterField(
model_name='company', model_name='company',
name='name', name='name',