jrd / django-oauth2-authcodeflow

Authenticate with any OpenId Connect/Oauth2 provider through authorization code flow. PKCE is also supported
https://pypi.org/project/django-oauth2-authcodeflow/
MIT License
14 stars 7 forks source link

Problem with migration #26

Closed woile closed 2 months ago

woile commented 2 months ago

It seems a migration was renamed and there are issues now: I have this migration from previous version 0004_alter_blacklistedtoken_id_and_more, and now it's called 0004_blacklistedtoken_constraint.py.

It creates the following error:

django.db.utils.ProgrammingError: relation "unique_username_token" already exists

Any idea how to fix it?

cpontvieux-systra commented 2 months ago

Yes, sorry about that :roll_eyes:

I was trying to address some problems related to some Mysql users (#21) by isolating the constraint in its own migration. So it can be skipped when the constraint could not be applied to the database.

Unfortunately, I also modified the previous migrations (to not include the constraint creation), but I didn’t modify those migration names (bad idea, I should not repeat it).

So, it’s working well from an empty database doing all the migrations, but yes, for an upgrade it fails :disappointed:

There is a solution though: just skip the migration (as you already have the constraint anyway)

$ python -m django migrate --fake oauth2_authcodeflow 0004
$ python -m django migrate

I can publish another version to pypi allowing the migration to fail successfully when the constraint already exist.