[Django] #33487: Adding `validate_slug` to a model's validators causes flapping migrations between 2.x and 3.x

8 views
Skip to first unread message

Django

unread,
Feb 1, 2022, 7:10:48 PM2/1/22
to django-...@googlegroups.com
#33487: Adding `validate_slug` to a model's validators causes flapping migrations
between 2.x and 3.x
-----------------------------------------+------------------------
Reporter: uraniumanchor | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I have a project that currently supports both 2.2 and 3.2 (working on 4.0
but there's some dependencies that need replacing) and as part of CI I
make sure that no PRs have bad or missing migrations. Problem is that 2.2
and 3.2 have different ideas of what `validate_slug` means because the
autogenerated migrations cannot agree between the two versions. It's
pretty easy to reproduce, just have a model with a field using the
`validate_slug` validator, create a migration using 2.2, then switch to
3.2 and check for migrations again. It seems like a string changed
somewhere that causes the migration auto-generator to think it needs a
change, but switching back to 2.2 and trying to generate the migrations
again will flap it right back.

I was able to work around it by editing the historical migration and
having it reference `validate_slug` directly instead of the
`RegexValidator` that it's an alias for, but that seems less than ideal.
Not sure how/if this can be addressed, but maybe if somebody else runs
into this issue they can find this ticket and use my workaround.

If this is unclear I can attach an example project.

--
Ticket URL: <https://code.djangoproject.com/ticket/33487>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 1, 2022, 7:43:15 PM2/1/22
to django-...@googlegroups.com
#33487: Adding `validate_slug` to a model's validators causes flapping migrations
between 2.x and 3.x
-------------------------------+--------------------------------------
Reporter: uraniumanchor | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => invalid


Comment:

Compatibility between Django versions isn't guaranteed for migrations. See
[https://docs.djangoproject.com/en/stable/topics/migrations/#supporting-
multiple-django-versions Supporting multiple Django versions].

--
Ticket URL: <https://code.djangoproject.com/ticket/33487#comment:1>

Reply all
Reply to author
Forward
0 new messages