ubyssey.ca icon indicating copy to clipboard operation
ubyssey.ca copied to clipboard

SQL migration fails on `dispatch.0001_initial`

Open psiemens opened this issue 1 year ago • 0 comments

What behavior were you expecting?

I started with an empty database and expected to successfully apply all migrations.

What actually happened?

The first migration (dispatch.0001_initial) failed with the error below.

Steps to reproduce

Run python manage.py migrate on a fresh database.

What was your environment like?

macOS Ventura 13.0 Python 3.11 mysql v8.0.33

Do you have any logs?

WARNINGS:
article.ArticlePage: ArticlePage.search_fields contains non-existent field 'author_id'
article.SpecialArticleLikePage: SpecialArticleLikePage.search_fields contains non-existent field 'author_id'
wagtailcore.WorkflowState: (models.W036) MySQL does not support unique constraints with conditions.
	HINT: A constraint won't be created. Silence this warning if you don't care about it.
Operations to perform:
  Apply all migrations: admin, ads, archive, article, auth, authors, authtoken, contenttypes, dbtemplates, dispatch, home, images, magazine, navigation, section, sessions, sites, specialfeaturelanding, sporttourney, taggit, videos, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailmenus, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
  Applying dispatch.0001_initial...Traceback (most recent call last):
  File "/Users/petersiemens/dev/ubyssey.ca/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/homebrew/lib/python3.11/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/homebrew/lib/python3.11/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/homebrew/lib/python3.11/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/homebrew/lib/python3.11/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 92, in database_forwards
    schema_editor.create_model(model)
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 353, in create_model
    self.create_model(field.remote_field.through)
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 343, in create_model
    sql, params = self.table_sql(model)
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 162, in table_sql
    definition, extra_params = self.column_sql(model, field)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 215, in column_sql
    db_params = field.db_parameters(connection=self.connection)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 1004, in db_parameters
    return {"type": self.db_type(connection), "check": self.db_check(connection)}
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 1001, in db_type
    return self.target_field.rel_db_type(connection=connection)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 897, in target_field
    return self.foreign_related_fields[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 644, in foreign_related_fields
    return tuple(rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field)
                                                       ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 632, in related_fields
    return self.resolve_related_fields()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 936, in resolve_related_fields
    related_fields = super().resolve_related_fields()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/django/db/models/fields/related.py", line 615, in resolve_related_fields
    raise ValueError('Related model %r cannot be resolved' % self.remote_field.model)
ValueError: Related model 'auth.Group' cannot be resolved

psiemens avatar Jun 30 '23 00:06 psiemens