Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IrreversibleError when migrating app zero for a new DB #495

Closed
raratiru opened this issue Sep 3, 2023 · 1 comment
Closed

IrreversibleError when migrating app zero for a new DB #495

raratiru opened this issue Sep 3, 2023 · 1 comment

Comments

@raratiru
Copy link

raratiru commented Sep 3, 2023

Expected behaviour

In a newly created and migrated database:
./manage.py migrate <my_custom_user_app> zero to reverse its migrations.

Actual behaviour

Receiving the error:

  Rendering model states... DONE
  Unapplying social_django.0015_rename_extra_data_new_usersocialauth_extra_data... OK
  Unapplying social_django.0014_remove_usersocialauth_extra_data... OK
  Unapplying social_django.0013_migrate_extra_data...Traceback (most recent call last):
  File "/project-home/./manage.py", line 24, in <module>
    main()
  File "/project-home/./manage.py", line 20, in main
    execute_from_command_line(sys.argv)
  File "/project-home/.venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/project-home/.venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/project-home/.venv/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/project-home/.venv/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project-home/.venv/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project-home/.venv/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/project-home/.venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 141, in migrate
    state = self._migrate_all_backwards(plan, full_plan, fake=fake)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project-home/.venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 219, in _migrate_all_backwards
    self.unapply_migration(states[migration], migration, fake=fake)
  File "/project-home/.venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 279, in unapply_migration
    state = migration.unapply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project-home/.venv/lib/python3.11/site-packages/django/db/migrations/migration.py", line 159, in unapply
    raise IrreversibleError(
django.db.migrations.exceptions.IrreversibleError: Operation <RunPython <function migrate_json_field at 0x7fc13a366ca0> elidable=True> in social_django.0013_migrate_extra_data is not reversible

What are the steps to reproduce this issue?

Input clear steps to reproduce the issue for a maintainer.

  1. Install the app
  2. Configure as per the docs:
SOCIAL_AUTH_JSONFIELD_ENABLED = True  # This can also be False, the error remains

AUTHENTICATION_BACKENDS = (
    "social_core.backends.github.GithubOAuth2",
    "django.contrib.auth.backends.ModelBackend",
)

TEMPLATES[0]["OPTIONS"]["context_processors"] += [
    "social_django.context_processors.backends",
    "social_django.context_processors.login_redirect",
]

SOCIAL_AUTH_PIPELINE = (
    'social_core.pipeline.social_auth.social_uid',
    'social_core.pipeline.social_auth.social_user',
    'social_core.pipeline.user.get_username',
    'social_core.pipeline.user.create_user',
    'social_core.pipeline.social_auth.associate_user',
)

SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ('username',)
  1. `./manage.py migrate
  2. `./manage.py migrate <my_user_app> zero
@nijel
Copy link
Member

nijel commented Sep 4, 2023

Migrations in #465 are not reversible. If you think it's worth addressing, patches are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants