question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot migrate wagtailcore to zero

See original GitHub issue

Running django-admin migrate wagtailcore zero fails as shown below, likely because of a missing dependency.

I suspect this is the reverse of the problem described in this comment.

Operations to perform:
  Unapply all migrations: wagtailcore
Running migrations:
  Rendering model states... DONE
  Unapplying wagtailsearchpromotions.0002_capitalizeverbose... OK
  Unapplying wagtailsearchpromotions.0001_initial... OK
  Unapplying wagtailsearch.0003_remove_editors_pick... OK
  Unapplying wagtailsearch.0002_add_verbose_names... OK
  Unapplying wagtailsearch.0001_initial... OK
  Unapplying wagtailredirects.0005_capitalizeverbose... OK
  Unapplying wagtailredirects.0004_set_unique_on_path_and_site... OK
  Unapplying wagtailredirects.0003_make_site_field_editable... OK
  Unapplying wagtailredirects.0002_add_verbose_names... OK
  Unapplying wagtailredirects.0001_initial... OK
  Unapplying wagtailimages.0012_copy_image_permissions_to_collections... OK
  Unapplying wagtailimages.0011_image_collection... OK
  Unapplying wagtailimages.0010_change_on_delete_behaviour... OK
  Unapplying wagtailimages.0009_capitalizeverbose... OK
  Unapplying wagtailimages.0008_image_created_at_index... OK
  Unapplying wagtailimages.0007_image_file_size... OK
  Unapplying wagtailimages.0006_add_verbose_names... OK
  Unapplying wagtailimages.0005_make_filter_spec_unique... OK
  Unapplying wagtailimages.0004_make_focal_point_key_not_nullable... OK
  Unapplying wagtailimages.0003_fix_focal_point_fields... OK
  Unapplying wagtailimages.0002_initial_data... OK
  Unapplying wagtailforms.0003_capitalizeverbose... OK
  Unapplying wagtailforms.0002_add_verbose_names... OK
  Unapplying wagtailforms.0001_initial... OK
  Unapplying wagtaildocs.0007_merge... OK
  Unapplying wagtaildocs.0006_copy_document_permissions_to_collections... OK
  Unapplying wagtaildocs.0005_document_collection... OK
  Unapplying wagtaildocs.0005_alter_uploaded_by_user_on_delete_action... OK
  Unapplying wagtaildocs.0004_capitalizeverbose... OK
  Unapplying wagtaildocs.0003_add_verbose_names... OK
  Unapplying wagtaildocs.0002_initial_data... OK
  Unapplying wagtailcore.0028_merge... OK
  Unapplying wagtailcore.0027_fix_collection_path_collation... OK
  Unapplying wagtailcore.0026_group_collection_permission... OK
  Unapplying wagtailcore.0025_collection_initial_data... OK
  Unapplying wagtailcore.0024_collection... OK
  Unapplying wagtailcore.0024_alter_page_content_type_on_delete_behaviour... OK
  Unapplying wagtailcore.0023_alter_page_revision_on_delete_behaviour... OK
  Unapplying wagtailcore.0022_add_site_name... OK
  Unapplying wagtailcore.0021_capitalizeverbose... OK
  Unapplying wagtailcore.0020_add_index_on_page_first_published_at... OK
  Unapplying wagtailcore.0019_verbose_names_cleanup... OK
  Unapplying wagtailcore.0018_pagerevision_submitted_for_moderation_index... OK
  Unapplying wagtailcore.0017_change_edit_page_permission_description... OK
  Unapplying wagtailadmin.0001_create_admin_access_permissions...Traceback (most recent call last):
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "wagtailcore_groupcollectionpermission" does not exist
LINE 1: DELETE FROM "wagtailcore_groupcollectionpermission" WHERE "w...
                    ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "~/.virtualenvs/project/bin/django-admin", line 11, in <module>
    sys.exit(execute_from_command_line())
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 200, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/migrations/executor.py", line 96, in migrate
    self._migrate_all_backwards(plan, full_plan, fake=fake)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_backwards
    self.unapply_migration(states[migration], migration, fake=fake)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/migrations/executor.py", line 218, in unapply_migration
    state = migration.unapply(state, schema_editor)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/migrations/migration.py", line 172, in unapply
    operation.database_backwards(self.app_label, schema_editor, from_state, to_state)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/migrations/operations/special.py", line 189, in database_backwards
    self.reverse_code(from_state.apps, schema_editor)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/wagtail/wagtailadmin/migrations/0001_create_admin_access_permissions.py", line 42, in remove_admin_access_permissions
    codename='access_admin',
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/models/query.py", line 600, in delete
    deleted, _rows_count = collector.delete()
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/models/deletion.py", line 292, in delete
    count = qs._raw_delete(using=self.using)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/models/query.py", line 614, in _raw_delete
    return sql.DeleteQuery(self.model).delete_qs(self, using)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/models/sql/subqueries.py", line 81, in delete_qs
    cursor = self.get_compiler(using).execute_sql(CURSOR)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 848, in execute_sql
    cursor.execute(sql, params)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "~/.virtualenvs/project/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "wagtailcore_groupcollectionpermission" does not exist
LINE 1: DELETE FROM "wagtailcore_groupcollectionpermission" WHERE "w...

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
PekopTcommented, Dec 20, 2016

upgrading from wagtail 1.0 to 1.8 caused following

Traceback (most recent call last):
  File "manage.py", line 18, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/PekopT/Virtualenvs/crm-py3/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/PekopT/Virtualenvs/crm-py3/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/PekopT/Virtualenvs/crm-py3/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/PekopT/Virtualenvs/crm-py3/lib/python3.4/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/Users/PekopT/Virtualenvs/crm-py3/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 86, in handle
    executor.loader.check_consistent_history(connection)
  File "/Users/PekopT/Virtualenvs/crm-py3/lib/python3.4/site-packages/django/db/migrations/loader.py", line 292, in check_consistent_history
    connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration wagtailadmin.0001_create_admin_access_permissions is applied before its dependency wagtailcore.0026_group_collection_permission on database 'default'.

Commenting this line is the solution https://github.com/wagtail/wagtail/commit/bee221b8c9626df725cae9372c301a03c8ed9bae#diff-c80f81bff2ea91134d39e7fd667808d5R51

I think something wrong with this solution.

2reactions
aaugustincommented, Apr 27, 2016

Workaround: run django-admin migrate wagtailadmin zero --fake then re-run django-admin migrate wagtailcore zero.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration error Wagtail - django - Stack Overflow
When I do a migration, I get an error: $ python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, ...
Read more >
Migrate your Wagtail Website from wagtailtrans to the new ...
This article describes one migration strategy on how to upgrade existing Wagtail websites (version <2.11) with wagtailtrans to the new ...
Read more >
Live migration process during maintenance events
Spot VMs can't live migrate to become standard VMs while they are running or be set to automatically restart when there is a...
Read more >
Migrations problem when integrating django-allauth
InvalidBasesError: Cannot resolve bases for [<ModelState: 'blog. ... makemigrations runs (no changes detected) by migrate fails.
Read more >
Common questions about the Migration and modernization tool
You can't begin a test migration until an initial replication (IR) has been completed for the VM. The test migration button will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found