jazzband / django-oauth-toolkit

OAuth2 goodies for the Djangonauts!
https://django-oauth-toolkit.readthedocs.io
Other
3.16k stars 794 forks source link

After getting this library upgrade token index removed #1520

Closed vipulprajapatiLTIM closed 2 weeks ago

vipulprajapatiLTIM commented 3 weeks ago

Describe the bug token index is being removed when we upgraded this library to 3.0.1

To Reproduce Upgrade library to 3.0.1 and apply migrations it will remove index on token column in access_token table.

Expected behavior Index should not have been dropped.

Version 3.0.1

yes

Additional context Got DB error while doing migrations image

n2ygk commented 3 weeks ago

Please copy/paste the text of the error messages rather than a screen shot as well as supply the Django version. I don't see why there'd be a reference to user_dump.json in the midst of the migrations unless you have customized them somehow.

vipulprajapatiLTIM commented 2 weeks ago

main issue is here in this migration https://github.com/jazzband/django-oauth-toolkit/blob/master/oauth2_provider/migrations/0012_add_token_checksum.py

token column datatype is changed so index is being dropped

n2ygk commented 2 weeks ago

That's because the update uses the token_checksum for the search for matching token. You can't index a long text column in many dstabase engines.

Do you now see an index on token_checksum? It's added here:

https://github.com/jazzband/django-oauth-toolkit/blob/1c5e36d59cd8f740650a72ad80a455f8ed05ff3c/oauth2_provider/migrations/0012_add_token_checksum.py#L35

vipulprajapatiLTIM commented 2 weeks ago

Got it. Thanks for clarification