title: wagtailimages.0016... migration error: Found wrong number (0) of constraints for wagtailimages_rendition
body: <p>While running the migrations from Wagtail 1.7 to 1.8 I'm getting the following migration error: </p>
  
  <pre><code> Applying wagtailimages.0016_deprecate_rendition_filter_relation...Traceback (most recent call last):
    File "djangoware/manage.py", line 10, in &lt;module&gt;
      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)
  </code></pre>
  
  <p>It's extremely likely that this isn't a clean migration as while trying to do a gradual upgrade from 1.6.1 to 1.6.3 to 1.7 and then to 1.8 a 3rd party app install attempted to jump forward to 1.8 so I had to try and clean the migration and try again.</p>
  
  <p>I'm quite happy to try and fix this manually via SQL if needed. The current state of the wagtailimages_rendition table is:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>And I note another project I have running on Wagtail 1.8 has the following:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>Help indicating the constraint alterations I need to do via SQL would likely be enough to solve the problem but any advice is appreciated.</p>