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

New 5.0.0 migrations fails: Found wrong number (0) of indexes #882

Open
blissdev opened this issue Nov 29, 2023 · 3 comments
Open

New 5.0.0 migrations fails: Found wrong number (0) of indexes #882

blissdev opened this issue Nov 29, 2023 · 3 comments

Comments

@blissdev
Copy link

After upgrading to 5.0.0 in our application long-using taggit, an error in the migration occurs. Any ideas to rectify?

  Applying taggit.0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx...Traceback (most recent call last):
  File "manage.py", line 13, in <module>
    execute_from_command_line(sys.argv)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/app/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/app/src/core/management/commands/resetdb.py", line 35, in handle
    create_database(options)
  File "/app/src/core/management/commands/resetdb.py", line 157, in create_database
    call_command("migrateall", interactive=False, verbosity=options["verbosity"])
  File "/app/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 198, in call_command
    return command.execute(*args, **defaults)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/app/src/legacybridge/management/commands/migrateall.py", line 16, in handle
    call_command("migrate", **options)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 198, in call_command
    return command.execute(*args, **defaults)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "/app/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
  File "/app/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "/app/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "/app/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/app/venv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 130, in apply
    operation.database_forwards(
  File "/app/venv/lib/python3.8/site-packages/django/db/migrations/operations/models.py", line 947, in database_forwards
    raise ValueError(
ValueError: Found wrong number (0) of indexes for taggit_taggeditem(content_type_id, object_id).

@blissdev blissdev changed the title New 5.0.0 migrations fails New 5.0.0 migrations fails: Found wrong number (0) of indexes Nov 29, 2023
@duaneking
Copy link

Does the index order in your db match what the migration expects?

@blissdev
Copy link
Author

blissdev commented Jan 1, 2024

@duaneking I'm not sure how to validate that, do you have any guidance?

@pigletto
Copy link

@blissdev I had the same issue with very old taggit installation (seems meanwhile some mess with migrations must have happened in the project). Anyway, try to connect directly to mysql using eg.

$ mysql -h yourhost -u youruser -p yourdbname

then display indexes:
$ SHOW INDEXES FROM taggit_taggeditem;

if index for content_type_id and object_id doesn't exist then execute:

$ create index taggit_tagg_content_8fc721_idx on taggit_taggeditem (content_type_id, object_id);

and run your django migrations again

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

No branches or pull requests

3 participants