mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Reverse migration company.0024
This commit is contained in:
parent
65791a2b9b
commit
f798537c73
@ -1,6 +1,14 @@
|
|||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def reverse_empty_email(apps, schema_editor):
|
||||||
|
Company = apps.get_model('company', 'Company')
|
||||||
|
for company in Company.objects.all():
|
||||||
|
if company.email == None:
|
||||||
|
company.email = ''
|
||||||
|
company.save()
|
||||||
|
|
||||||
|
|
||||||
def make_empty_email_field_null(apps, schema_editor):
|
def make_empty_email_field_null(apps, schema_editor):
|
||||||
Company = apps.get_model('company', 'Company')
|
Company = apps.get_model('company', 'Company')
|
||||||
for company in Company.objects.all():
|
for company in Company.objects.all():
|
||||||
@ -23,7 +31,7 @@ class Migration(migrations.Migration):
|
|||||||
field=models.EmailField(blank=True, help_text='Contact email address', max_length=254, null=True, unique=False, verbose_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
|
# Convert empty email string to NULL
|
||||||
migrations.RunPython(make_empty_email_field_null),
|
migrations.RunPython(make_empty_email_field_null, reverse_code=reverse_empty_email),
|
||||||
# Remove unique constraint on name field
|
# Remove unique constraint on name field
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='company',
|
model_name='company',
|
||||||
|
Loading…
Reference in New Issue
Block a user