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

Avoid possible migration failure #680

Closed Honza-m closed 1 year ago

Honza-m commented 3 years ago

Django migrations are applied in random order unless a dependency is specified. This file specifies dependency to the first migration of the cms module, however it also requires the cms.Placeholder model which is only defined in subsequent migration files of the cms module. This means that if Django decides to only apply the first migration of the cms module, followed by the first migration of the djangocms_blog module (which is valid since there are no further dependencies), the migration process will fail because cms.CMSPlugin has not been created yet. This happens in my project all the time. The proposed change ensures that all cms migrations are finished before djangocms_blog migrations start, hence enabling the migration process to succeed.

yakky commented 2 years ago

@Honza-m thanks a lot for your suggestion. You are right stating that "first" is not a good migration dependency declaration, but I have been burnt a few times by "latest" too. I think it's safe to pick a reasonable actual django CMS migration to depend on. A good candidate it's "0022_auto_20180620_1551" which is part of django CMS 3.7 which the oldest version we support as of now

yakky commented 1 year ago

@Honza-m this has been fixed in #722 by replacing first with a proper django-cms migration

Thanks a lot for your suggestion