Fix up some issues with oauth2_provider evolutions.
Review Request #14905 — Created March 14, 2026 and submitted
When adding evolutions for oauth2_provider I got a little lazy and just
ignored theRunPythonstuff in their migrations. It turns out that we
actually need to populate the token_checksum field in the same way that
they do, first creating the field as blank, populated it with hashes of
each of the items, and then finally fixing it to be non-blank.This also adds a post-upgrade step to save application
client_secret
fields, causing any unhashed items to be fixed.Finally, I've set a couple additional flags on the conversion of the
tokenfield to be aTextField, removing the max length and unique
parameters.
Did test upgrades from 4.0.6, 5.0.7, 6.0.2, and 7.0.4 schemas.
Previously I was getting failures on the 4.0.6 and 5.0.7 ones.
| Summary | ID |
|---|---|
| lwuwtszpxvmntxyumnryryxqxrruyptq |
| Description | From | Last Updated |
|---|---|---|
|
Can we make this a Sequence? |
|
|
|
The ) would look nicer on the next line. |
|
|
|
While probably okay, these aren't doing any quoting. Look in Django Evolution where we assign a qn from an import … |
|
|
|
Sorry, I wasn't clear on this. I meant the table and row names. So like: return [ (f'UPDATE {qn("oauth2_provider_accesstoken")} ...) … |
|
- Commits:
-
Summary ID lwuwtszpxvmntxyumnryryxqxrruyptq lwuwtszpxvmntxyumnryryxqxrruyptq
Checks run (2 succeeded)
-
-
Sorry, I wasn't clear on this. I meant the table and row names. So like:
return [ (f'UPDATE {qn("oauth2_provider_accesstoken")} ...) ... ]This just better mirrors how Django Evolution constructs all of its own SQL, and avoids things like possible conflicts (say, if
idholds a special meaning). A Better Safe Than Sorry sort of thing. That'll be single quotes, double quotes, or backticks, depending on the backend.The values going into that tuple automatically get quoted through
SQLExecutorfor capture purposes in Django Evolution and for execution in Django, so we don't want to quote those.
- Commits:
-
Summary ID lwuwtszpxvmntxyumnryryxqxrruyptq lwuwtszpxvmntxyumnryryxqxrruyptq
Checks run (2 succeeded)
- Commits:
-
Summary ID lwuwtszpxvmntxyumnryryxqxrruyptq lwuwtszpxvmntxyumnryryxqxrruyptq