Closed iscilyas closed 2 years ago
Thanks for the report @iscilyas, this is an interesting issue.
Wagtail 4.0 changed PageRevision
to a more generic Revision
model, and it is a tad difficult to go account for that in our code since we have an FK to the revision model. Will try to fix this somehow.
It is possible that you could get around this by running ./manage migrate wagtail.core
before ./manage.py migrate
.
This is why I released an alpha first as I knew I did not catch all the gremlins
Thanks for the quick response @zerolab!
It is possible that you could get around this by running ./manage migrate wagtail.core before ./manage.py migrate.
Doesn't work unfortunately :( same error message (tried migrate wagtail.core
as well as migrate wagtailcore
) ;)
I think I found a solution, PR coming shortly
Potential fix in #616. Can you try locally with pip install git+https://github.com/wagtail/wagtail-localize.git@chore/wagtail4-revision-migration-dependency
?
Potential fix in #616. Can you try locally with
pip install git+https://github.com/wagtail/wagtail-localize.git@chore/wagtail4-revision-migration-dependency
?
This time it didn't force-upgrade django (4.0.7) or wagtail (3.0.3)... and different error but still broken :(
l$ ./manage.py makemigrations
Traceback (most recent call last):
File "/var/www/html/imrozrum.k12.tr/wagtail/./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/commands/makemigrations.py", line 169, in handle
loader.project_state(),
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/loader.py", line 361, in project_state
return self.graph.make_state(
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/graph.py", line 329, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 89, in mutate_state
operation.state_forwards(self.app_label, new_state)
AttributeError: 'function' object has no attribute 'state_forwards'
hmm.. did you run ./manage.py migrate
first?
hmm.. did you run
./manage.py migrate
first?
$ ./manage.py migrate
System check identified some issues:
WARNINGS:
wagtailcore.WorkflowState: (models.W036) MariaDB 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, auth, base, contenttypes, gallery, home, news, people, projects, sessions, site_settings, sites, taggit, wagtail_localize, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
Applying wagtail_localize.0016_wagtail4_revision_model...Traceback (most recent call last):
File "/var/www/html/imrozrum.k12.tr/wagtail/./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 290, in handle
post_migrate_state = executor.migrate(
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 131, in migrate
state = self._migrate_all_forwards(
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards
state = self.apply_migration(
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 248, in apply_migration
state = migration.apply(state, schema_editor)
File "/var/www/html/imrozrum.k12.tr/wagtail/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 117, in apply
operation.state_forwards(self.app_label, project_state)
AttributeError: 'function' object has no attribute 'state_forwards'
oh, wait.. can you re-install? there was an early issue which I fixed
OK. update: so patch works fine with django 4.1.1 and wagtail 4.0.1 ... earlier error was with django 4.0.7 and wagtail 3.0.3. fwiw.
$ ./manage.py migrate
System check identified some issues:
WARNINGS:
wagtailcore.WorkflowState: (models.W036) MariaDB 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, auth, base, contenttypes, gallery, home, news, people, projects, sessions, site_settings, sites, taggit, wagtail_localize, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
Applying wagtailcore.0070_rename_pagerevision_revision... OK
Applying wagtailcore.0071_populate_revision_content_type... OK
Applying wagtailcore.0072_alter_revision_content_type_notnull... OK
Applying wagtailcore.0073_page_latest_revision... OK
Applying wagtailcore.0074_revision_object_str... OK
Applying wagtailcore.0075_populate_latest_revision_and_revision_object_str... OK
Applying wagtailcore.0076_modellogentry_revision... OK
Applying wagtail_localize.0016_wagtail4_revision_model... OK
oh, wait.. can you re-install? there was an early issue which I fixed
sure. do you want me to try with django 4.0.7 wagtail 3.0.3 or is that expected to not work? (actually... i've already done the migrations so not sure if i can downgrade?)
do you want me to try with django 4.0.7 wagtail 3.0.3 or is that expected to not work if you have a copy of the database pre-upgrade, then that would help test.
It should work as migration 0016 is conditional. and essentially is an empty migration with Wagtail < 4.0, but I mistakenly added migrations.RunPython.noop
which failed, so that should be fixed.
I will make a new release (alpha) tomorrow morning
do you want me to try with django 4.0.7 wagtail 3.0.3 or is that expected to not work if you have a copy of the database pre-upgrade, then that would help test.
database backups? what's that? :P
yeah i tried your "fixed" version on my test machine using the pre-upgrade database and yeah everything looks good!
Great job, and thanks for responding and resolving this so quickly!
Oh wait...
So upgrading wagtail-localize
(fixed version) was fine but after that when i upgraded wagtail/django the migration failed with the same (initial) error:
✗ ./manage.py migrate
System check identified some issues:
WARNINGS:
?: (wagtailadmin.W003) The WAGTAILADMIN_BASE_URL setting is not defined
HINT: This should be the base URL used to access the Wagtail admin site. Without this, URLs in notification emails will not display correctly.
Traceback (most recent call last):
File "/home/ilias/wagtail/imrozrum/./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 117, in handle
executor.loader.check_consistent_history(connection)
File "/home/ilias/wagtail/imrozrum/venv/lib/python3.10/site-packages/django/db/migrations/loader.py", line 327, in check_consistent_history
raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration wagtail_localize.0016_wagtail4_revision_model is applied before its dependency wagtailcore.0076_modellogentry_revision on database 'default'.
This is a bit of a chicken and egg situation. It upgraded fine, and marked 0016 as applied (noop). Then with Wagtail 4, the migration check kicks in and as 0016 is applied and it has 0076_modellogentry_revision as a dependency.. it fails
Will sleep on it
@iscilyas can you re-install #616 and give it another try?
I've released alpha 2 (with the fix in #616 and without migration 0016 which turns out was not needed)
I've released alpha 2 (with the fix in #616 and without migration 0016 which turns out was not needed)
yeah looks good. i just tried it.
I've been waiting for a wagtail 4.0-compatible wagtail-localize, so I guess I'm one of the earliest adopters...
After upgrading django/wagtail/wagtail-localize (from 1.2.1) I'm seeing the following error when running
makemigrations
:Anyone else seeing this?