You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(wagtail): replace empty migration directories with MIGRATION_MODULES workflow
The actual approach is to configure MIGRATION_MODULES in settings and run
makemigrations to generate MongoDB-compatible migrations, not ship empty __init__.py packages.
Copy file name to clipboardExpand all lines: docs/design/wagtail-support.rst
+7-13Lines changed: 7 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,22 @@ Overview
8
8
9
9
Wagtail is a Django-based CMS with its own migration history, admin URL patterns, and serialization assumptions. Several of those assumptions are incompatible with MongoDB out of the box. The template ships with a set of targeted patches and conventions that make Wagtail work with ``django-mongodb-backend`` without forking Wagtail itself.
10
10
11
-
Empty Migration Directories
12
-
----------------------------
13
-
14
-
**Decision: redirect all Wagtail app migrations to empty in-project directories**
11
+
Migration Modules
12
+
------------------
15
13
16
-
Wagtail ships with its own migration files (``wagtail/migrations/0001_initial.py``, etc.). On MongoDB those migrations are not needed: the driver creates collections automatically on first insert. Running them would also fail because they include SQL-style ``ALTER TABLE`` assumptions.
14
+
**Decision: configure ``MIGRATION_MODULES`` in settings and generate migrations with ``makemigrations``**
17
15
18
-
The ``WAGTAIL_MIGRATION_MODULES`` dict in the project's ``settings/wagtail.py`` redirects every Wagtail app to an empty package inside the project's own ``migrations/`` directory:
16
+
Wagtail ships with its own migration files that include SQL-style assumptions incompatible with MongoDB. The project's ``settings/wagtail.py`` uses ``MIGRATION_MODULES`` to redirect each Wagtail app to an in-project package:
Each of those packages contains only an ``__init__.py``. Django sees zero migration files and skips the app during ``migrate``, while MongoDB creates the underlying collections on demand.
29
-
30
-
**Why not ``MIGRATION_MODULES = {"wagtailcore": None}``?**
31
-
32
-
Setting an app to ``None`` opts it into Django's syncdb path. When an app that inherits from a migration-framework app (e.g. ``wagtailcore``) is itself set to ``None``, Django raises ``InvalidBasesError: Cannot resolve bases for [<ModelState: 'home.HomePage'>]`` because it cannot reconcile the inheritance hierarchy across the syncdb/migration boundary. Empty directories avoid this entirely — both sides participate in the migration framework with zero files each, so no base resolution is attempted.
26
+
Run ``manage.py makemigrations`` after configuring this to generate MongoDB-compatible migration files for each app. Django will use these in-project migrations instead of the ones bundled with Wagtail.
0 commit comments