nephila / djangocms-blog

django CMS blog application - Support for multilingual posts, placeholders, social network meta tags and configurable apphooks
https://djangocms-blog.readthedocs.io
BSD 3-Clause "New" or "Revised" License
403 stars 190 forks source link

makemigrations fails with cmsplugin-filer 1.1 #320

Closed electroniceagle closed 8 years ago

electroniceagle commented 8 years ago

We have a make migrations dry run test that is failing because of the ThumbnailOption move. I think the issue is that some of the migration steps refer to cmsplugin_filer_image.ThumbnailOption and others expect cmsplugin_filer.ThumbnailOption when parsing all of the historical migrations files. I'm not sure if we'll have to do some conditional magic in the old migrations. Investigating now.

$ pip freeze | grep filer
cmsplugin-filer==1.1.3rc1
django-filer==1.2.4

./manage.py makemigrations --dry-run --noinput -v 3 --exit ; test 1 -eq $?
System check identified some issues:
Traceback (most recent call last):
  File "./manage.py", line 20, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 125, in handle
    migration_name=self.migration_name,
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 43, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 110, in _detect_changes
    self.old_apps = self.from_state.concrete_apps
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/db/migrations/state.py", line 170, in concrete_apps
    self.apps = StateApps(self.real_apps, self.models, ignore_swappable=True)
  File "/Users/bschott/.virtualenvs/sites/lib/python2.7/site-packages/django/db/migrations/state.py", line 248, in __init__
    raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field djangocms_blog.Post.main_image_full: cmsplugin_filer_image.ThumbnailOption

Note, migrate passes just fine.

DEBUG=True ./manage.py migrate --fake-initial --noinput
Operations to perform:
  Synchronize unmigrated apps: allauth, debug_toolbar, aloe_django, captcha, django_extensions, ajax_select, sekizai, rest_framework, treebeard, bootstrapform, bootstrap3, s3_folder_storage, nimbis_core, raven_contrib_django, meta_mixin, cms_bootstrap3, extra_fields, aldryn_apphooks_config, parler, django_select2, theme, clipboard, storages, segmentation, mptt, sharable, gunicorn, email_extras, staticfiles, djangocms_admin_style, sitemaps, compressor, link, multiselectfield, taggit_autosuggest, admindocs, messages, widget_tweaks, meta, analytical, django_feedparser
  Apply all migrations: shop, repository_core, redirects, cmsplugin_filer_teaser, djangocms_picture, filer, shop_richcatalog, session_ec2, session_core, djangocms_page_meta, django_ses, shop_ec2product, site_common, easy_thumbnails, djangocms_snippet, cmsplugin_filer_file, forms, openid, djangocms_file, cmsplugin_cascade, openid_provider, user_profile, central_message, sites, cmsplugin_feedparser, menus, contenttypes, shop_richproduct, guardian, repository_s3, djangocms_vimeo, shop_core, organizations_core, cmsplugin_filer_image, cmsplugin_tabs, guac_auth, cmsplugin_forms_builder, sessions, djangocms_column, shop_urlproduct, robots, auth, cmsplugin_filer_folder, cmsplugin_collapse, address, djangocms_style, organizations, account, addressmodel, messages_extends, admin, djangocms_blog, djangocms_video, site_nimbisservices, socialaccount, taggit, shop_contactusproduct, djangocms_text_ckeditor, cms, cmsplugin_filer_video, djangocms_teaser
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying cms.0016_auto_20160608_1535... OK
  Applying cmsplugin_cascade.0012_auto_20160824_0959... OK
  Applying cmsplugin_filer_file.0003_filerfile_link_attributes... OK
  Applying cmsplugin_filer_file.0004_auto_20160705_1334... OK
  Applying cmsplugin_filer_file.0005_auto_20160713_1853... OK
  Applying cmsplugin_filer_folder.0003_auto_20160713_1853... OK
  Applying cmsplugin_filer_image.0003_mv_thumbnail_option_to_filer_20160119_1720... OK
  Applying cmsplugin_filer_image.0004_auto_20160120_0950... OK
  Applying cmsplugin_filer_image.0005_auto_20160224_1457... OK
  Applying cmsplugin_filer_image.0006_auto_20160427_1438... OK
  Applying cmsplugin_filer_image.0007_filerimage_link_attributes... OK
  Applying cmsplugin_filer_image.0008_auto_20160705_1334... OK
  Applying cmsplugin_filer_image.0009_auto_20160713_1853... OK
  Applying cmsplugin_filer_teaser.0003_auto_20160713_1853... OK
  Applying cmsplugin_filer_video.0003_auto_20160713_1853... OK
  Applying djangocms_blog.0021_auto_20160823_2008... OK
  Applying djangocms_text_ckeditor.0004_auto_20160706_1339... OK
  Applying djangocms_video.0003_field_adaptions... OK
  Applying djangocms_video.0004_move_to_attributes... OK
  Applying djangocms_video.0005_migrate_to_filer... OK
  Applying djangocms_video.0006_field_adaptions... OK
  Applying djangocms_video.0007_create_nested_plugin... OK
yakky commented 8 years ago

which djangocms-blog versions are you migrating from / to ?

electroniceagle commented 8 years ago

I'm trying to migrate to djangocms-blog==0.8.7 from 0.8.6. However, it isn't migrate command that is effected, it is when you manage.py makemigrations.

yakky commented 8 years ago

Yeah, I meant upgrading

yakky commented 8 years ago

@electroniceagle confirmed. Thanks for spotting this. 0.8.8 is on the way

yakky commented 8 years ago

@electroniceagle could you please test https://github.com/nephila/djangocms-blog/archive/hotfix/thumbnail_model.zip ?

electroniceagle commented 8 years ago

Still the same exception as above. I'm now debugging with python -m pdb manage.py makemigrations --dry-run to trace. Will post some more state soon.

(Pdb) p self._pending_lookups.items()
[((u'cmsplugin_filer_image', u'ThumbnailOption'), [(<class 'Post'>, <django.db.models.fields.related.ForeignKey: main_image_full>, <function resolve_related_class at 0x111df9758>), (<class 'Post'>, <django.db.models.fields.related.ForeignKey: main_image_thumbnail>, <function resolve_related_class at 0x111df9ed8>)])]
electroniceagle commented 8 years ago
(Pdb) app_configs[35].models['post'].main_image_thumbnail.field.__dict__
{'_validators': [], 'auto_created': False, 'serialize': True, '_unique': False, 'unique_for_year': None, 'blank': True, 'help_text': u'', 'null': True, 'to_fields': [None], 'db_tablespace': '', 'db_index': True, 'is_relation': True, 'unique_for_month': None, 'unique_for_date': None, 'primary_key': False, 'concrete': True, 'swappable': True, 'max_length': None, 'rel': <ManyToOneRel: djangocms_blog.post>, 'from_fields': [u'self'], 'verbose_name': u'main image thumbnail', '_choices': [], 'creation_counter': 157343, 'editable': True, 'error_messages': {u'unique': <django.utils.functional.__proxy__ object at 0x10906b3d0>, u'invalid': <django.utils.functional.__proxy__ object at 0x1090e3e50>, u'invalid_choice': <django.utils.functional.__proxy__ object at 0x10906b1d0>, u'blank': <django.utils.functional.__proxy__ object at 0x10906b390>, u'null': <django.utils.functional.__proxy__ object at 0x10906b350>, u'unique_for_date': <django.utils.functional.__proxy__ object at 0x10906b410>}, '_error_messages': None, 'db_constraint': True, '_verbose_name': u'main image thumbnail', 'name': u'main_image_thumbnail', 'db_column': None, 'default': <class django.db.models.fields.NOT_PROVIDED at 0x1090592c0>, 'attname': u'main_image_thumbnail_id', 'column': u'main_image_thumbnail_id', 'model': <class 'Post'>, 'opts': <Options for Post>}
(Pdb)
electroniceagle commented 8 years ago

I am wondering if this is happening here: https://github.com/divio/cmsplugin-filer/blob/develop/cmsplugin_filer_image/migrations/0001_initial.py#L72

yakky commented 8 years ago

@electroniceagle how does your project compare to this sample https://github.com/yakky/blog-demo, especially WRT requirements, django version etc

electroniceagle commented 8 years ago

requirements.txt

Unless I'm missing it, I don't see any major differences. I'll try the demo config and look at settings...

electroniceagle commented 8 years ago

@yakky I had to float a few unrelated app versions to get pip to install, but looks like this worked (column and googlemap have issues, but not the problem we're fixing). I've recreated my virtualenv multiple times, but was able to recreate having djangocms-blog 0.8.5 installed via pip and 0.8.7 installed via ./manage.py develop. I'm going to go nuke my original virtualenv for the 100th time and make sure I purge pip versions before testing my large pile of apps. Thanks for the sanity check demo.

[blog-demo] bschott@ironman-2 ~/Source/blog-demo (master)
$ pip freeze
aldryn-apphooks-config==0.2.7
aldryn-boilerplates==0.7.4
aldryn-common==1.0.4
aldryn-search==0.2.12
cmsplugin-filer==1.1.3rc1
dj-database-url==0.4.1
Django==1.8.14
django-appconf==1.0.2
django-appdata==0.1.5
django-classy-tags==0.8.0
django-cms==3.3.2
django-filer==1.2.4
django-formtools==1.0
django-haystack==2.5.0
django-meta==1.3.1
django-meta-mixin==0.3.0
django-mptt==0.8.6
django-parler==1.6.5
django-polymorphic==0.8.1
django-reversion==1.10.2
django-sekizai==0.10.0
Django-Select2==4.3.2
django-sortedm2m==1.3.2
django-spurl==0.6.4
django-standard-form==1.1.1
django-taggit==0.21.2
django-taggit-autosuggest==0.3.0
django-taggit-templatetags==0.2.5
django-templatetag-sugar==1.0
django-treebeard==4.0.1
djangocms-admin-style==1.2.3
djangocms-apphook-setup==0.1.2
djangocms-attributes-field==0.1.1
-e git+git@github.com:nephila/djangocms-blog.git@ab7929648effd815b2d56eaef51d54fe1107ff15#egg=djangocms_blog
djangocms-column==1.6.0
djangocms-googlemap==0.5.1
djangocms-installer==0.9rc3
djangocms-link==1.8.2
djangocms-snippet==1.8.2
djangocms-style==1.7.0
djangocms-text-ckeditor==3.1.0
djangocms-video==1.1.0
easy-thumbnails==2.3
html5lib==0.9999999
lxml==3.6.4
Pillow==3.3.1
pytz==2016.6.1
six==1.10.0
tzlocal==1.2.2
Unidecode==0.4.19
URLObject==2.4.2
YURL==0.13

[blog-demo] bschott@ironman-2 ~/Source/blog-demo (master)
$ ./manage.py makemigrations --dry-run
Migrations for 'djangocms_column':
  0002_auto_20160901_2259.py:
    - Alter field cmsplugin_ptr on column
    - Alter field cmsplugin_ptr on multicolumns
Migrations for 'djangocms_googlemap':
  0003_auto_20160901_2259.py:
    - Alter field style on googlemap
electroniceagle commented 8 years ago

I can confirm that hotfix/thumbnail_model fixed the issue. Thanks! Close when merged?

yakky commented 8 years ago

@electroniceagle thanks, merging now and releasing 0.8.8 soon! Thanks for reporting and testing