djangocms-blog
djangocms-blog copied to clipboard
Avoid possible migration failure
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.
@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
@Honza-m this has been fixed in #722 by replacing first
with a proper django-cms migration
Thanks a lot for your suggestion