from django.db import migrations, models

def preserve_locked_topics(apps, schema_editor):
    ForumTopic=apps.get_model('engagement','ForumTopic')
    ForumTopic.objects.filter(locked=True).update(allow_replies=False)

class Migration(migrations.Migration):
    dependencies=[('engagement','0002_serviceevent_scope')]
    operations=[
        migrations.AddField(model_name='forumtopic',name='allow_replies',field=models.BooleanField(default=True)),
        migrations.RunPython(preserve_locked_topics,migrations.RunPython.noop),
    ]
