Skip to content

Commit c4abebe

Browse files
committed
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.
1 parent a010246 commit c4abebe

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

docs/design/wagtail-support.rst

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,22 @@ Overview
88

99
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.
1010

11-
Empty Migration Directories
12-
----------------------------
13-
14-
**Decision: redirect all Wagtail app migrations to empty in-project directories**
11+
Migration Modules
12+
------------------
1513

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``**
1715

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:
1917

2018
.. code-block:: python
2119
22-
WAGTAIL_MIGRATION_MODULES = {
20+
MIGRATION_MODULES = {
2321
"wagtailcore": "myproject.migrations.wagtailcore",
2422
"wagtailadmin": "myproject.migrations.wagtailadmin",
25-
# ... one empty __init__.py per app
23+
# ... one entry per Wagtail app
2624
}
2725
28-
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.
3327

3428
No ``home`` App
3529
---------------

0 commit comments

Comments
 (0)