Merge pull request #266 from nephila/feature/better_migratoins

Refactor migration dependencies to avoid issue when going backward
This commit is contained in:
Iacopo Spalletti 2016-05-28 09:02:19 +02:00
commit aa66465e4e
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):
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 = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
migrations.swappable_dependency(ACTUAL_FILER_IMAGE_MODEL),
('cms', '__latest__'),
('taggit', '__latest__'),
('filer', '__latest__'),
('cmsplugin_filer_image', '__latest__'),
]
('cms', '__first__'),
('taggit', '__first__'),
] + filer_dependencies
operations = [
migrations.CreateModel(

View file

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

View file

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

View file

@ -10,7 +10,7 @@ from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('cms', '__latest__'),
('cms', '__first__'),
('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_NAMESPACE = get_setting('CURRENT_NAMESPACE')
try:
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
except ImportError:
try: # pragma: no cover
from filer.models import ThumbnailOption # NOQA
try:
thumbnail_model = '%s.%s' % (
ThumbnailOption._meta.app_label, ThumbnailOption._meta.model_name
)
except AttributeError:
thumbnail_model = '%s.%s' % (
ThumbnailOption._meta.app_label, ThumbnailOption._meta.module_name
)
thumbnail_model = 'filer.ThumbnailOption'
except ImportError: # pragma: no cover
from cmsplugin_filer_image.models import ThumbnailOption # NOQA
thumbnail_model = 'cmsplugin_filer_image.ThumbnailOption'
try: