Repository: wagtail/wagtail

Issue:
Upstream change in django-treebeard 4.5 requires a new wagtail core migration
Default MP_Node depth has changed to 1.

https://github.com/django-treebeard/django-treebeard/commit/454be8f29ac2b4b4fbe6512357b5afc1eb422bab#diff-35501ef525349cd39e4713d1a9f64a249fa4fbd31d875513e3a15e65988701a2


Discussion:
@bretth Thanks for the report! Looks like this change could potentially make things pretty messy, and I think we'll have to get a patch release out as soon as possible to pin to <4.5 - as it stands, if someone upgrades to 4.5 now and runs `./manage.py makemigrations`, it'll create a spurious 'auto' migration inside the wagtail.core app which will then be lost on subsequent Wagtail upgrades.
For anyone who may be experiencing lingering issues after upgrading, I'm hoping this helps:

### If on Wagtail 2.12:

1. Search your project for migrations with a dependency on a `wagtailcore` migration with a name starting with `0062_auto` or `0063_auto` and replace those dependency lines with `("wagtailcore", "0061_change_promote_tab_helpt_text_and_verbose_names")`.
2. Run `python manage.py migrate` to check that it runs without any issues.
3. Commit your changes and deploy them wherever they need deploying.
3. From a bash console run the following to remove the reference to the spurious migration in any environment that may have created/run it:
```
echo "DELETE FROM django_migrations WHERE app='wagtailcore' AND (name LIKE '0062_auto%' OR name LIKE '0063_auto%')" | python manage.py dbshell
```

### If on Wagtail 2.11:

1. Search your project for migrations with a dependency on a `wagtailcore` migration with a name starting with `0060_auto` or `0061_auto` and replace those dependency lines with `("wagtailcore", "0059_apply_collection_ordering")`.
2. Run `python manage.py migrate` to check that it runs without any issues.
3. Commit your changes and deploy them wherever they need deploying.
4. From a bash console run the following to remove the reference to the spurious migration in any environment that may have created/run it:
```
echo "DELETE FROM django_migrations WHERE app='wagtailcore' AND (name LIKE '0060_auto%' OR name LIKE '0061_auto%')" | python manage.py dbshell
```


### If on Wagtail 2.10:

1. Search your project for migrations with a dependency on a `wagtailcore` migration with a name starting with `0053_auto` or `0054_auto` and replace those dependency lines with `("wagtailcore", "0052_pagelogentry")`.
2. Run `python manage.py migrate` to check that it runs without any issues.
3. Commit your changes and deploy them wherever they need deploying.
4. From a bash console run the following to remove the reference to the spurious migration in any environment that may have created/run it:
```
echo "DELETE FROM django_migrations WHERE app='wagtailcore' AND (name LIKE '0053_auto%' OR name LIKE '0054_auto%')" | python manage.py dbshell
```

### If on Wagtail 2.8 or 2.9:

1. Search your project for migrations with a dependency on a `wagtailcore` migration with a name starting with `0046_auto` or `0047_auto` and replace those dependency lines with `("wagtailcore", "0045_assign_unlock_grouppagepermission")`.
2. Run `python manage.py migrate` to check that it runs without any issues.
3. Commit your changes and deploy them wherever they need deploying.
4. From a bash console run the following to remove the reference to the spurious migration in any environment that may have created/run it:
```
echo "DELETE FROM django_migrations WHERE app='wagtailcore' AND (name LIKE '0046_auto%' OR name LIKE '0047_auto%')" | python manage.py dbshell
```


Now that treebeard 4.5.1 has been released with the model change reverted (and the 4.5 release pulled), we can un-pin the dependency - tagging this to be done in the next 2.11 (and 2.12) release.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -23,7 +23,7 @@
     "Django>=2.2,<3.2",
     "django-modelcluster>=5.1,<6.0",
     "django-taggit>=1.0,<2.0",
-    "django-treebeard>=4.2.0,<4.5",
+    "django-treebeard>=4.2.0,<5.0,!=4.5",
     "djangorestframework>=3.11.1,<4.0",
     "django-filter>=2.2,<3.0",
     "draftjs_exporter>=2.1.5,<3.0",


Test patch: