#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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.a375c65cc4b5c24edd98222043ebc649%40djangoproject.com.