Merge first and second level menu items#550
Conversation
Noticed an error during the migration on production data
|
When testing your migration on a database with production data, the following error is thrown: Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.ObjectInUse: cannot DROP TABLE "core_firstlevelmenuitem" because it has pending trigger events
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 389, in database_forwards
schema_editor.delete_model(model)
File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 487, in delete_model
self.execute(
File "/usr/local/lib/python3.11/site-packages/django/db/backends/postgresql/schema.py", line 48, in execute
return super().execute(sql, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 201, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: cannot DROP TABLE "core_firstlevelmenuitem" because it has pending trigger eventsCould be related to https://stackoverflow.com/a/12838113, as this error does not occur when splitting the |
e84b301 to
6e7e985
Compare
|
|
||
| class FirstLevelMenuItem(BasePage): | ||
| class MenuItem(BasePage): | ||
| parent_page_types = ["RootPage"] |
There was a problem hiding this comment.
MenuItem is missing here
|
I've just noticed that the |
Hmm, for me with sqlite this is not the case. Need to investigate |
|
I was able to reproduce it in the local setup with SQLite using the following steps:
|
|
I'm stumped on how to fix this. Setting the visible_for value in the shell later works in the way it is done in the migration (I also tried using set() suggested by ChatGPT), also stepping through it seems visible_for is set for the new item. Maybe the delete of the old menuitem triggers the removal of the relationship at a later point and thus the newly set relationship is then deleted again? |
Even without migration 0014 (deletion of old menu item models), the permissions are still lost for me. |
Yes I mean the individual object delete() calls |
|
The migration now preserves permission. However, I've received an error when accessing some menu items after the migration. Will investigate… |
|
@lukasrad02 Did you have any further insights on this? |
|
Sorry, I've been tracing down the wrong path for quite a while, but I think I have identified the underlying issue now. The revision model from wagatil references the object it is a revision of. This includes the type of model: https://github.com/wagtail/wagtail/blob/72b965cd94726e9fa0ceb64f10ef7ef88476fb2c/wagtail/models/__init__.py#L2866C5-L2868C6. After our migration, the revisions of the menu items are still pointing to content types I have set the correct I would propose to update the |
Bumps [django-debug-toolbar](https://github.com/jazzband/django-debug-toolbar) from 4.3.0 to 4.4.2. - [Release notes](https://github.com/jazzband/django-debug-toolbar/releases) - [Changelog](https://github.com/jazzband/django-debug-toolbar/blob/main/docs/changes.rst) - [Commits](django-commons/django-debug-toolbar@4.3...4.4.2) --- updated-dependencies: - dependency-name: django-debug-toolbar dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [wagtail-markdown](https://github.com/torchbox/wagtail-markdown) from 0.11.1 to 0.12.1. - [Release notes](https://github.com/torchbox/wagtail-markdown/releases) - [Changelog](https://github.com/torchbox/wagtail-markdown/blob/main/CHANGELOG.md) - [Commits](torchbox/wagtail-markdown@v0.11.1...v0.12.1) --- updated-dependencies: - dependency-name: wagtail-markdown dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.5.1 to 7.5.3. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](coveragepy/coveragepy@7.5.1...7.5.3) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.1.0 to 3.2.3. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](pylint-dev/pylint@v3.1.0...v3.2.3) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [django-bootstrap-icons](https://github.com/christianwgd/django-bootstrap-icons) from 0.8.7 to 0.9.0. - [Release notes](https://github.com/christianwgd/django-bootstrap-icons/releases) - [Changelog](https://github.com/christianwgd/django-bootstrap-icons/blob/master/CHANGELOG.md) - [Commits](christianwgd/django-bootstrap-icons@0.8.7...v0.9.0) --- updated-dependencies: - dependency-name: django-bootstrap-icons dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.2.5 to 3.2.6. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](pylint-dev/pylint@v3.2.5...v3.2.6) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [django](https://github.com/django/django) from 5.0.6 to 5.0.8. - [Commits](django/django@5.0.6...5.0.8) --- updated-dependencies: - dependency-name: django dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.6.0 to 7.6.1. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](coveragepy/coveragepy@7.6.0...7.6.1) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [black](https://github.com/psf/black) from 24.4.2 to 24.8.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](psf/black@24.4.2...24.8.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
* use generated html for TencaListOptionsForm * Render label as HTML tag connected to the input * Add field for footer property Depends on tzwenn/tenca#1 * Use tenca 0.0.3 * Update lockfile * Run formatter --------- Co-authored-by: Julian B <jeriox@users.noreply.github.com>
Bumps [djlint](https://github.com/djlint/djLint) from 1.34.1 to 1.35.2. - [Release notes](https://github.com/djlint/djLint/releases) - [Changelog](https://github.com/djlint/djLint/blob/master/CHANGELOG.md) - [Commits](djlint/djLint@v1.34.1...v1.35.2) --- updated-dependencies: - dependency-name: djlint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [wagtail-localize](https://github.com/wagtail/wagtail-localize) from 1.9 to 1.9.1. - [Release notes](https://github.com/wagtail/wagtail-localize/releases) - [Changelog](https://github.com/wagtail/wagtail-localize/blob/main/CHANGELOG.md) - [Commits](wagtail/wagtail-localize@v1.9...v1.9.1) --- updated-dependencies: - dependency-name: wagtail-localize dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [wagtail](https://github.com/wagtail/wagtail) from 6.2 to 6.2.1. - [Release notes](https://github.com/wagtail/wagtail/releases) - [Changelog](https://github.com/wagtail/wagtail/blob/main/CHANGELOG.txt) - [Commits](wagtail/wagtail@v6.2...v6.2.1) --- updated-dependencies: - dependency-name: wagtail dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.2.6 to 3.3.1. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](pylint-dev/pylint@v3.2.6...v3.3.1) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.2 to 8.3.3. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@8.3.2...8.3.3) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [django-select2](https://github.com/codingjoe/django-select2) from 8.2.0 to 8.2.1. - [Release notes](https://github.com/codingjoe/django-select2/releases) - [Commits](codingjoe/django-select2@8.2.0...8.2.1) --- updated-dependencies: - dependency-name: django-select2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
|
@lukasrad02 I updated the content type, you could test it again Also I guess I messed up the history, but we can squash this |
|
Now we're again losing permissions on some menu items. I'll try to investigate further, but on the first glance, I have no idea why only some pages are affected… |
|
If I did not miss anything, only second level menu items are affected by the permission loss. Changing the migration 13 so that we first migrate second level menu items fixes the issue and both first- and second-level menu items keep the assigned permissions. |
Backup before applying these migrations would be wise.