Refactor migration dependencies to avoid issue when going backward

This commit is contained in:
Iacopo Spalletti 2016-05-27 22:47:04 +02:00
parent 0a5814c0f5
commit 8e6ab53036
No known key found for this signature in database
GPG key ID: BDCBC2EB289F60C6
5 changed files with 22 additions and 19 deletions

View file

@ -17,14 +17,23 @@ ACTUAL_FILER_IMAGE_MODEL = FILER_IMAGE_MODEL or 'filer.Image'
class Migration(migrations.Migration): class Migration(migrations.Migration):
if 'cmsplugin_filer' not in thumbnail_model:
filer_dependencies = [
('filer', '0003_thumbnailoption'),
('cmsplugin_filer_image', '0006_auto_20160427_1438')
]
else:
filer_dependencies = [
('filer', '__first__'),
('cmsplugin_filer_image', '__first__'),
]
dependencies = [ dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency(ACTUAL_FILER_IMAGE_MODEL), migrations.swappable_dependency(ACTUAL_FILER_IMAGE_MODEL),
('cms', '__latest__'), ('cms', '__first__'),
('taggit', '__latest__'), ('taggit', '__first__'),
('filer', '__latest__'), ] + filer_dependencies
('cmsplugin_filer_image', '__latest__'),
]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(

View file

@ -7,7 +7,7 @@ from django.db import models, migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('sites', '__latest__'), ('sites', '__first__'),
('djangocms_blog', '0001_initial'), ('djangocms_blog', '0001_initial'),
] ]

View file

@ -31,7 +31,7 @@ def migrate_tags_reverse(apps, schema_editor):
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('taggit', '__latest__'), ('taggit', '__first__'),
('djangocms_blog', '0008_auto_20150814_0831'), ('djangocms_blog', '0008_auto_20150814_0831'),
] ]

View file

@ -10,7 +10,7 @@ from django.db import models, migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('cms', '__latest__'), ('cms', '__first__'),
('djangocms_blog', '0009_latestpostsplugin_tags_new'), ('djangocms_blog', '0009_latestpostsplugin_tags_new'),
] ]

View file

@ -32,18 +32,12 @@ from .settings import get_setting
BLOG_CURRENT_POST_IDENTIFIER = get_setting('CURRENT_POST_IDENTIFIER') BLOG_CURRENT_POST_IDENTIFIER = get_setting('CURRENT_POST_IDENTIFIER')
BLOG_CURRENT_NAMESPACE = get_setting('CURRENT_NAMESPACE') BLOG_CURRENT_NAMESPACE = get_setting('CURRENT_NAMESPACE')
try: try: # pragma: no cover
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
except ImportError:
from filer.models import ThumbnailOption # NOQA from filer.models import ThumbnailOption # NOQA
try: thumbnail_model = 'filer.ThumbnailOption'
thumbnail_model = '%s.%s' % ( except ImportError: # pragma: no cover
ThumbnailOption._meta.app_label, ThumbnailOption._meta.model_name from cmsplugin_filer_image.models import ThumbnailOption # NOQA
) thumbnail_model = 'cmsplugin_filer_image.ThumbnailOption'
except AttributeError:
thumbnail_model = '%s.%s' % (
ThumbnailOption._meta.app_label, ThumbnailOption._meta.module_name
)
try: try: