Merge pull request #283 from nephila/feature/thumbnailoption_migrations

Fix thumbnailoption migrations
This commit is contained in:
Iacopo Spalletti 2016-06-25 18:28:04 +02:00 committed by GitHub
commit e9a5e8fa46
5 changed files with 183 additions and 16 deletions

View file

@ -56,6 +56,36 @@ Supported django CMS versions:
Some plugins have a broken tag management prior to 0.6, in case Some plugins have a broken tag management prior to 0.6, in case
you have issues with tags, upgrade to latest version to have it fixed. you have issues with tags, upgrade to latest version to have it fixed.
Upgrading cmsplugin-filer from 1.0 to 1.1
-----------------------------------------
Due to changes in cmsplugin-filer/filer which moved ``ThumbnailOption`` model from the
former to the latter, ``djangocms-blog`` must be migrated as well.
Migrating cmsplugin-filer to 1.1 and djangocms-blog up to 0.8.4
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
If you have djangocms-blog up to 0.8.4 (included) installed or you are upgrading from a previous
djangocms-blog version together with cmsplugin-filer upgrade, you can just apply the migrations::
pip install cmsplugin-filer==1.1.1 django-filer==1.2.2 djangocms-blog==0.8.4
python manage.py migrate
Migrating cmsplugin-filer to 1.1 and djangocms-blog 0.8.5+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
If you already a djangocms-blog 0.8.5+ or above, you have to de-apply some blog migrations when
doing the upgrade::
python manage.py migrate djangocms_blog 0017 ## reverse for these migration is a noop
pip install cmsplugin-filer==1.1.1 django-filer==1.2.2
python manage.py migrate
.. note:: de-apply migration **before** upgrading cmsplugin-filer. If running before upgrade, the
backward migration won't alter anything on the database, and it will just allow the code
to migrate ``ThumbnailOption`` from cmsplugin-filer to filer
Features Features
-------- --------

View file

@ -16,6 +16,23 @@ class Migration(migrations.Migration):
run_before = [ run_before = [
('cmsplugin_filer_image', '0004_auto_20160120_0950'), ('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: else:
dependencies = [ dependencies = [
('filer', '__first__'), ('filer', '__first__'),
@ -23,19 +40,4 @@ class Migration(migrations.Migration):
('djangocms_blog', '0016_auto_20160502_1741'), ('djangocms_blog', '0016_auto_20160502_1741'),
] ]
operations = [ 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),
),
]

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 = []