Migrate prefixes
This commit is contained in:
1 parent
7902767f3b
commit
6ea07b462e
1 file changed
+13
@@ -4,6 +4,18 @@ from __future__ import unicode_literals
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
def normalize_prefixes(apps, schema_editor):
|
||||
Prefix = apps.get_model("mailadmin", "Prefix")
|
||||
OrgUnit = apps.get_model("mailadmin", "OrgUnit")
|
||||
|
||||
for ou in OrgUnit.objects.all():
|
||||
Prefix.objects.create(name=ou.prefix, orgunit=ou)
|
||||
|
||||
|
||||
def noop(*args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@@ -22,6 +34,7 @@ class Migration(migrations.Migration):
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.RunPython(normalize_prefixes, noop),
|
||||
migrations.RemoveField(
|
||||
model_name='orgunit',
|
||||
name='prefix',
|
||||
|
||||
Reference in new issue
Block a user