Moar migration fixes

This commit is contained in:
Iacopo Spalletti 2016-06-25 17:10:28 +02:00
parent 0fc168e147
commit 1f484c625d
No known key found for this signature in database
GPG key ID: BDCBC2EB289F60C6
4 changed files with 153 additions and 16 deletions

View file

@ -16,6 +16,23 @@ class Migration(migrations.Migration):
run_before = [
('cmsplugin_filer_image', '0004_auto_20160120_0950'),
]
operations = [
migrations.AlterField(
model_name='post',
name='main_image_full',
field=models.ForeignKey(related_name='djangocms_blog_post_full',
verbose_name='Main image full', blank=True,
to=thumbnail_model, null=True),
),
migrations.AlterField(
model_name='post',
name='main_image_thumbnail',
field=models.ForeignKey(related_name='djangocms_blog_post_thumbnail',
verbose_name='Main image thumbnail', blank=True,
to=thumbnail_model, null=True),
),
]
else:
dependencies = [
('filer', '__first__'),
@ -23,19 +40,4 @@ class Migration(migrations.Migration):
('djangocms_blog', '0016_auto_20160502_1741'),
]
operations = [
migrations.AlterField(
model_name='post',
name='main_image_full',
field=models.ForeignKey(related_name='djangocms_blog_post_full',
verbose_name='Main image full', blank=True,
to=thumbnail_model, null=True),
),
migrations.AlterField(
model_name='post',
name='main_image_thumbnail',
field=models.ForeignKey(related_name='djangocms_blog_post_thumbnail',
verbose_name='Main image thumbnail', blank=True,
to=thumbnail_model, null=True),
),
]
operations = []

View file

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from djangocms_blog.models import thumbnail_model
class Migration(migrations.Migration):
if 'cmsplugin_filer' not in thumbnail_model:
dependencies = [
('djangocms_blog', '0017_thumbnail_move'),
('filer', '0003_thumbnailoption'),
('cmsplugin_filer_image', '0003_mv_thumbnail_option_to_filer_20160119_1720'),
]
run_before = [
('cmsplugin_filer_image', '0004_auto_20160120_0950'),
]
operations = [
migrations.AddField(
model_name='post',
name='main_image_full_new',
field=models.ForeignKey(related_name='djangocms_blog_post_full',
verbose_name='Main image full', blank=True,
to=thumbnail_model, null=True),
),
migrations.AddField(
model_name='post',
name='main_image_thumbnail_new',
field=models.ForeignKey(related_name='djangocms_blog_post_thumbnail',
verbose_name='Main image thumbnail', blank=True,
to=thumbnail_model, null=True),
),
]
else:
dependencies = [
('filer', '__first__'),
('cmsplugin_filer_image', '__first__'),
('djangocms_blog', '0017_thumbnail_move'),
]
operations = []

View file

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from djangocms_blog.models import thumbnail_model
def move_thumbnail_opt_to_filer(apps, schema_editor):
Post = apps.get_model('djangocms_blog', 'Post')
for post in Post.objects.all():
post.main_image_full_new_id = post.main_image_full_id
post.main_image_thumbnail_new_id = post.main_image_thumbnail_id
post.save()
def move_thumbnail_opt_to_plugin(apps, schema_editor):
Post = apps.get_model('djangocms_blog', 'Post')
for post in Post.objects.all():
post.main_image_full_id = post.main_image_full_new_id
post.main_image_thumbnail_id = post.main_image_thumbnail_new_id
post.save()
class Migration(migrations.Migration):
if 'cmsplugin_filer' not in thumbnail_model:
dependencies = [
('djangocms_blog', '0018_thumbnail_move2'),
('filer', '0003_thumbnailoption'),
('cmsplugin_filer_image', '0003_mv_thumbnail_option_to_filer_20160119_1720'),
]
run_before = [
('cmsplugin_filer_image', '0004_auto_20160120_0950'),
]
operations = [
migrations.RunPython(move_thumbnail_opt_to_filer, move_thumbnail_opt_to_plugin),
]
else:
dependencies = [
('filer', '__first__'),
('cmsplugin_filer_image', '__first__'),
('djangocms_blog', '0018_thumbnail_move2'),
]
operations = []

View file

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from djangocms_blog.models import thumbnail_model
class Migration(migrations.Migration):
if 'cmsplugin_filer' not in thumbnail_model:
dependencies = [
('djangocms_blog', '0019_thumbnail_move3'),
('filer', '0003_thumbnailoption'),
('cmsplugin_filer_image', '0003_mv_thumbnail_option_to_filer_20160119_1720'),
]
run_before = [
('cmsplugin_filer_image', '0004_auto_20160120_0950'),
]
operations = [
migrations.RemoveField(
model_name='post',
name='main_image_full'
),
migrations.RemoveField(
model_name='post',
name='main_image_thumbnail',
),
migrations.RenameField(
model_name='post',
old_name='main_image_full_new',
new_name='main_image_full',
),
migrations.RenameField(
model_name='post',
old_name='main_image_thumbnail_new',
new_name='main_image_thumbnail',
)
]
else:
dependencies = [
('filer', '__first__'),
('cmsplugin_filer_image', '__first__'),
('djangocms_blog', '0019_thumbnail_move3'),
]
operations = []