diff --git a/ietf/message/migrations/0009_fix_address_lists.py b/ietf/message/migrations/0009_fix_address_lists.py new file mode 100644 index 000000000..736225da8 --- /dev/null +++ b/ietf/message/migrations/0009_fix_address_lists.py @@ -0,0 +1,43 @@ +# Copyright The IETF Trust 2020, All Rights Reserved +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-05-21 14:27 + + +from __future__ import absolute_import, print_function, unicode_literals + +from tqdm import tqdm + +from django.db import migrations + +import debug # pyflakes:ignore + + +def forward(apps, schema_editor): + + Message = apps.get_model('message', 'Message') + + for m in tqdm(Message.objects.all()): + dirty = False + for fieldname in ['to', 'cc', 'bcc', ]: + f = getattr(m, fieldname) + if f.startswith("['") or f.startswith('[]') or f.startswith("[u'"): + l = eval(f) + if isinstance(l, list): + f = ','.join(l) + setattr(m, fieldname, f) + dirty = True + if dirty: + m.save() + +def reverse(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('message', '0008_set_message_sent'), + ] + + operations = [ + migrations.RunPython(forward, reverse), + ]