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 8 forks source link

Irreversible migrations #22

Open pinoatrome opened 2 months ago

pinoatrome commented 2 months ago

The unapply operation of migrations fails:

./manage.py migrate oauth2_authcodeflow zero

 File "/Users/pinoatrome/.virtualenvs/my-project/lib/python3.11/site-packages/django/db/migrations/migration.py", line 159, in unapply
    raise IrreversibleError(
django.db.migrations.exceptions.IrreversibleError: Operation <RunPython <function forwards at 0x108c94680>> in oauth2_authcodeflow.0003_auto_20210528_1432 is not reversible

This is because some migrations use RunPython with only forward function, missing reverse function.

From docs on RunPython

"The reverse_code argument is called when unapplying migrations. This callable should undo what is done in the code callable so that the migration is reversible. If reverse_code is None (the default), the RunPython operation is irreversible."

aliyuldashev commented 1 month ago

make one simple fuction inside of you RunPython for example:

def to_pass_reverse():
     pass
...
migrations.RunPython(...., to_pass_reverse)

It should work