djangocms-blog icon indicating copy to clipboard operation
djangocms-blog copied to clipboard

Avoid possible migration failure

Open Honza-m opened this issue 3 years ago • 1 comments

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 avatar Jun 30 '21 15:06 Honza-m

@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 avatar Jul 28 '22 21:07 yakky

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

Thanks a lot for your suggestion

yakky avatar Apr 20 '23 21:04 yakky