wagtailimages.0016... migration error: Found wrong number (0) of constraints for wagtailimages_rendition
wagtailimages.0016... migration error: Found wrong number (0) of constraints for wagtailimages_rendition
当 运行 从 Wagtail 1.7 迁移到 1.8 时,我收到以下迁移错误:
Applying wagtailimages.0016_deprecate_rendition_filter_relation...Traceback (most recent call last):
File "djangoware/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 532, in database_forwards
getattr(new_model._meta, self.option_name, set()),
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 329, in alter_unique_together
self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 83, in _delete_composed_index
return super(DatabaseSchemaEditor, self)._delete_composed_index(model, fields, *args)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 358, in _delete_composed_index
", ".join(columns),
ValueError: Found wrong number (0) of constraints for wagtailimages_rendition(image_id, filter_id, focal_point_key)
这极有可能不是一次干净的迁移,因为在尝试从 1.6.1 逐步升级到 1.6.3 到 1.7 然后升级到 1.8 时,第 3 方应用程序安装试图跳转到 1.8,所以我不得不尝试清理迁移并重试。
如果需要,我很乐意尝试通过 SQL 手动修复此问题。 wagtailimages_rendition table 的当前状态是:
CREATE TABLE `wagtailimages_rendition` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`file` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`width` int(11) NOT NULL,
`height` int(11) NOT NULL,
`filter_id` int(11) DEFAULT NULL,
`image_id` int(11) NOT NULL,
`focal_point_key` varchar(17) COLLATE utf8_unicode_ci NOT NULL,
`filter_spec2` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`filter_spec` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `wagtailimages_rendition_f33175e6` (`image_id`),
KEY `wagtailimages_rendition_0a317463` (`filter_id`),
KEY `wagtailimages_rendition_58c64917` (`filter_spec`)
) ENGINE=InnoDB AUTO_INCREMENT=352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
我注意到我在 Wagtail 1.8 上的另一个项目 运行 具有以下内容:
CREATE TABLE `wagtailimages_rendition` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`file` varchar(100) NOT NULL,
`width` int(11) NOT NULL,
`height` int(11) NOT NULL,
`focal_point_key` varchar(255) NOT NULL,
`filter_id` int(11) DEFAULT NULL,
`image_id` int(11) NOT NULL,
`filter_spec` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `wagtailimages_rendition_image_id_323c8fe0_uniq` (`image_id`,`filter_spec`,`focal_point_key`),
KEY `wagtailimages_rend_filter_id_7fc52567_fk_wagtailimages_filter_id` (`filter_id`),
KEY `wagtailimages_rendition_58c64917` (`filter_spec`),
KEY `wagtailimages_rendition_f33175e6` (`image_id`),
CONSTRAINT `wagtailimages_rend_filter_id_7fc52567_fk_wagtailimages_filter_id` FOREIGN KEY (`filter_id`) REFERENCES `wagtailimages_filter` (`id`),
CONSTRAINT `wagtailimages_rendit_image_id_3e1fd774_fk_wagtailimages_image_id` FOREIGN KEY (`image_id`) REFERENCES `wagtailimages_image` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=272 DEFAULT CHARSET=utf8;
通过 SQL 帮助指示我需要进行的约束更改可能足以解决问题,但欢迎任何建议。
我最好的猜测是您受到了 Wagtail 1.8 中这个错误的影响:https://github.com/wagtail/wagtail/issues/3256
这会导致迁移 0016 通过以下操作失败 part-way:
migrations.AlterUniqueTogether(
name='rendition',
unique_together=set([('image', 'filter_spec', 'focal_point_key')]),
),
涉及删除对 (image_id、filter_id、focal_point_key) 的唯一约束并在 (image_id、filter_spec、 focal_point_key)。后者失败是因为它超过了 MySQL 在某些配置上的长度限制。
要修复它,请确保您安装了 Wagtail 1.8.1(看起来您已经安装了,因为它已成功将 focal_point_key
的长度减少到 17 个字符)。然后,要将数据库状态恢复到迁移 0016 之前的正确状态,运行:
ALTER TABLE wagtailimages_rendition ADD UNIQUE KEY wagtailimages_rendition_image_id_uniq (image_id, filter_id, focal_point_key);
现在 manage.py migrate
应该有望完成剩余的迁移。
当 运行 从 Wagtail 1.7 迁移到 1.8 时,我收到以下迁移错误:
Applying wagtailimages.0016_deprecate_rendition_filter_relation...Traceback (most recent call last):
File "djangoware/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 532, in database_forwards
getattr(new_model._meta, self.option_name, set()),
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 329, in alter_unique_together
self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 83, in _delete_composed_index
return super(DatabaseSchemaEditor, self)._delete_composed_index(model, fields, *args)
File "/Users/nicklo/.virtualenvs/theproject/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 358, in _delete_composed_index
", ".join(columns),
ValueError: Found wrong number (0) of constraints for wagtailimages_rendition(image_id, filter_id, focal_point_key)
这极有可能不是一次干净的迁移,因为在尝试从 1.6.1 逐步升级到 1.6.3 到 1.7 然后升级到 1.8 时,第 3 方应用程序安装试图跳转到 1.8,所以我不得不尝试清理迁移并重试。
如果需要,我很乐意尝试通过 SQL 手动修复此问题。 wagtailimages_rendition table 的当前状态是:
CREATE TABLE `wagtailimages_rendition` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`file` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`width` int(11) NOT NULL,
`height` int(11) NOT NULL,
`filter_id` int(11) DEFAULT NULL,
`image_id` int(11) NOT NULL,
`focal_point_key` varchar(17) COLLATE utf8_unicode_ci NOT NULL,
`filter_spec2` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`filter_spec` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `wagtailimages_rendition_f33175e6` (`image_id`),
KEY `wagtailimages_rendition_0a317463` (`filter_id`),
KEY `wagtailimages_rendition_58c64917` (`filter_spec`)
) ENGINE=InnoDB AUTO_INCREMENT=352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
我注意到我在 Wagtail 1.8 上的另一个项目 运行 具有以下内容:
CREATE TABLE `wagtailimages_rendition` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`file` varchar(100) NOT NULL,
`width` int(11) NOT NULL,
`height` int(11) NOT NULL,
`focal_point_key` varchar(255) NOT NULL,
`filter_id` int(11) DEFAULT NULL,
`image_id` int(11) NOT NULL,
`filter_spec` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `wagtailimages_rendition_image_id_323c8fe0_uniq` (`image_id`,`filter_spec`,`focal_point_key`),
KEY `wagtailimages_rend_filter_id_7fc52567_fk_wagtailimages_filter_id` (`filter_id`),
KEY `wagtailimages_rendition_58c64917` (`filter_spec`),
KEY `wagtailimages_rendition_f33175e6` (`image_id`),
CONSTRAINT `wagtailimages_rend_filter_id_7fc52567_fk_wagtailimages_filter_id` FOREIGN KEY (`filter_id`) REFERENCES `wagtailimages_filter` (`id`),
CONSTRAINT `wagtailimages_rendit_image_id_3e1fd774_fk_wagtailimages_image_id` FOREIGN KEY (`image_id`) REFERENCES `wagtailimages_image` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=272 DEFAULT CHARSET=utf8;
通过 SQL 帮助指示我需要进行的约束更改可能足以解决问题,但欢迎任何建议。
我最好的猜测是您受到了 Wagtail 1.8 中这个错误的影响:https://github.com/wagtail/wagtail/issues/3256
这会导致迁移 0016 通过以下操作失败 part-way:
migrations.AlterUniqueTogether(
name='rendition',
unique_together=set([('image', 'filter_spec', 'focal_point_key')]),
),
涉及删除对 (image_id、filter_id、focal_point_key) 的唯一约束并在 (image_id、filter_spec、 focal_point_key)。后者失败是因为它超过了 MySQL 在某些配置上的长度限制。
要修复它,请确保您安装了 Wagtail 1.8.1(看起来您已经安装了,因为它已成功将 focal_point_key
的长度减少到 17 个字符)。然后,要将数据库状态恢复到迁移 0016 之前的正确状态,运行:
ALTER TABLE wagtailimages_rendition ADD UNIQUE KEY wagtailimages_rendition_image_id_uniq (image_id, filter_id, focal_point_key);
现在 manage.py migrate
应该有望完成剩余的迁移。