Opened 2 years ago

Closed 2 years ago

#33487 closed Bug (invalid)

Adding `validate_slug` to a model's validators causes flapping migrations between 2.x and 3.x

Reported by: Benjamin Cutler Owned by: nobody
Component: Migrations Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (1)

comment:1 by Tim Graham, 2 years ago

Resolution: invalid
Status: newclosed

Compatibility between Django versions isn't guaranteed for migrations. See Supporting multiple Django versions.

Note: See TracTickets for help on using tickets.
Back to Top