# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-10-14 13:25 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion from django.db.models import Q class Migration(migrations.Migration): dependencies = [ ('boards', '0064_remove_post_version'), ] def attachment_alias_to_sticker(apps, schema_editor): Attachment = apps.get_model('boards', 'Attachment') AttachmentSticker = apps.get_model('boards', 'AttachmentSticker') attachments = Attachment.objects.exclude(Q(alias=None) | Q(alias='')) for attachment in attachments: AttachmentSticker.objects.create(attachment=attachment, name=attachment.alias) operations = [ migrations.CreateModel( name='AttachmentSticker', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.TextField(unique=True)), ('attachment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='boards.Attachment')), ], ), migrations.RunPython(attachment_alias_to_sticker), migrations.RemoveField( model_name='Attachment', name='alias', ) ]