We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Need to document focal_point_key changes for people who use custom image models
Everyone who uses custom image models need to create a new migration to make the `focal_point_key` field on rendition not nullable. Also, South doesn't automatically add the `default=''` into the migration (even though it's set on the field) which would cause the migration to fail.

The migration may also fail if you have duplicate renditions (this applies to everyone, not just custom image model people). The following SQL query should delete them:

```
DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (SELECT image_id || '-' || filter_id FROM (SELECT image_id, filter_id, COUNT(*) AS count FROM wagtailimages_rendition GROUP BY image_id, filter_id) AS renditions WHERE count > 1);
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3 
4 from south.utils import datetime_utils as datetime
5 from south.db import db
6 from south.v2 import SchemaMigration
7 from django.db import models
8 
9 
10 class Migration(SchemaMigration):
11 
12     def forwards(self, orm):
13 
14         # Changing field 'Rendition.focal_point_key'
15         db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, default=''))
16 
17     def backwards(self, orm):
18 
19         # Changing field 'Rendition.focal_point_key'
20         db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, null=True))
21 
22     models = {
23         'auth.group': {
24             'Meta': {'object_name': 'Group'},
25             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
26             'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
27             'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
28         },
29         'auth.permission': {
30             'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
31             'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
32             'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
33             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
34             'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
35         },
36         'auth.user': {
37             'Meta': {'object_name': 'User'},
38             'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
39             'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
40             'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
41             'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'user_set'", 'blank': 'True', 'to': "orm['auth.Group']"}),
42             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
43             'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
44             'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
45             'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
46             'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
47             'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
48             'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
49             'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'user_set'", 'blank': 'True', 'to': "orm['auth.Permission']"}),
50             'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
51         },
52         'contenttypes.contenttype': {
53             'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
54             'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
55             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
56             'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
57             'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
58         },
59         'wagtailimages.filter': {
60             'Meta': {'object_name': 'Filter'},
61             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
62             'spec': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})
63         },
64         'wagtailimages.image': {
65             'Meta': {'object_name': 'Image'},
66             'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
67             'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
68             'focal_point_height': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
69             'focal_point_width': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
70             'focal_point_x': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
71             'focal_point_y': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
72             'height': ('django.db.models.fields.IntegerField', [], {}),
73             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
74             'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
75             'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
76             'width': ('django.db.models.fields.IntegerField', [], {})
77         },
78         'wagtailimages.rendition': {
79             'Meta': {'unique_together': "(('image', 'filter', 'focal_point_key'),)", 'object_name': 'Rendition'},
80             'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
81             'filter': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': "orm['wagtailimages.Filter']"}),
82             'focal_point_key': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
83             'height': ('django.db.models.fields.IntegerField', [], {}),
84             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
85             'image': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'renditions'", 'to': "orm['wagtailimages.Image']"}),
86             'width': ('django.db.models.fields.IntegerField', [], {})
87         }
88     }
89 
90     complete_apps = ['wagtailimages']
```

Path: `wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3 
4 from django.db import models, migrations
5 
6 
7 class Migration(migrations.Migration):
8 
9     dependencies = [
10         ('wagtailimages', '0003_fix_focal_point_fields'),
11     ]
12 
13     operations = [
14         migrations.AlterField(
15             model_name='rendition',
16             name='focal_point_key',
17             field=models.CharField(blank=True, default='', max_length=255, editable=False),
18         ),
19     ]
20
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py b/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py
--- a/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py
+++ b/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py
@@ -4,6 +4,13 @@
 from django.db import models, migrations
 
 
+def remove_duplicate_renditions(apps, schema_editor):
+    schema_editor.execute("""
+        DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (
+            SELECT image_id || '-' || filter_id FROM wagtailimages_rendition WHERE focal_point_key IS NULL GROUP BY image_id, filter_id HAVING COUNT(*) > 1
+        ) AND focal_point_key IS NULL
+    """)
+
 class Migration(migrations.Migration):
 
     dependencies = [
@@ -11,6 +18,7 @@
     ]
 
     operations = [
+        migrations.RunPython(remove_duplicate_renditions),
         migrations.AlterField(
             model_name='rendition',
             name='focal_point_key',
diff --git a/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py b/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py
--- a/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py
+++ b/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py
@@ -10,6 +10,12 @@
 class Migration(SchemaMigration):
 
     def forwards(self, orm):
+        # remove duplicate renditions
+        db.execute("""
+            DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (
+                SELECT image_id || '-' || filter_id FROM wagtailimages_rendition WHERE focal_point_key IS NULL GROUP BY image_id, filter_id HAVING COUNT(*) > 1
+            ) AND focal_point_key IS NULL
+        """)
 
         # Changing field 'Rendition.focal_point_key'
         db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, default=''))

{"golden_diff": "diff --git a/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py b/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py\n--- a/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py\n+++ b/wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py\n@@ -4,6 +4,13 @@\n from django.db import models, migrations\n \n \n+def remove_duplicate_renditions(apps, schema_editor):\n+    schema_editor.execute(\"\"\"\n+        DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (\n+            SELECT image_id || '-' || filter_id FROM wagtailimages_rendition WHERE focal_point_key IS NULL GROUP BY image_id, filter_id HAVING COUNT(*) > 1\n+        ) AND focal_point_key IS NULL\n+    \"\"\")\n+\n class Migration(migrations.Migration):\n \n     dependencies = [\n@@ -11,6 +18,7 @@\n     ]\n \n     operations = [\n+        migrations.RunPython(remove_duplicate_renditions),\n         migrations.AlterField(\n             model_name='rendition',\n             name='focal_point_key',\ndiff --git a/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py b/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py\n--- a/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py\n+++ b/wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py\n@@ -10,6 +10,12 @@\n class Migration(SchemaMigration):\n \n     def forwards(self, orm):\n+        # remove duplicate renditions\n+        db.execute(\"\"\"\n+            DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (\n+                SELECT image_id || '-' || filter_id FROM wagtailimages_rendition WHERE focal_point_key IS NULL GROUP BY image_id, filter_id HAVING COUNT(*) > 1\n+            ) AND focal_point_key IS NULL\n+        \"\"\")\n \n         # Changing field 'Rendition.focal_point_key'\n         db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, default=''))\n", "issue": "Need to document focal_point_key changes for people who use custom image models\nEveryone who uses custom image models need to create a new migration to make the `focal_point_key` field on rendition not nullable. Also, South doesn't automatically add the `default=''` into the migration (even though it's set on the field) which would cause the migration to fail.\n\nThe migration may also fail if you have duplicate renditions (this applies to everyone, not just custom image model people). The following SQL query should delete them:\n\n```\nDELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (SELECT image_id || '-' || filter_id FROM (SELECT image_id, filter_id, COUNT(*) AS count FROM wagtailimages_rendition GROUP BY image_id, filter_id) AS renditions WHERE count > 1);\n```\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom south.utils import datetime_utils as datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n\nclass Migration(SchemaMigration):\n\n    def forwards(self, orm):\n\n        # Changing field 'Rendition.focal_point_key'\n        db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, default=''))\n\n    def backwards(self, orm):\n\n        # Changing field 'Rendition.focal_point_key'\n        db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, null=True))\n\n    models = {\n        'auth.group': {\n            'Meta': {'object_name': 'Group'},\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\n            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'})\n        },\n        'auth.permission': {\n            'Meta': {'ordering': \"('content_type__app_label', 'content_type__model', 'codename')\", 'unique_together': \"(('content_type', 'codename'),)\", 'object_name': 'Permission'},\n            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['contenttypes.ContentType']\"}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n        },\n        'auth.user': {\n            'Meta': {'object_name': 'User'},\n            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\n            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': \"'user_set'\", 'blank': 'True', 'to': \"orm['auth.Group']\"}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\n            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': \"'user_set'\", 'blank': 'True', 'to': \"orm['auth.Permission']\"}),\n            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\n        },\n        'contenttypes.contenttype': {\n            'Meta': {'ordering': \"('name',)\", 'unique_together': \"(('app_label', 'model'),)\", 'object_name': 'ContentType', 'db_table': \"'django_content_type'\"},\n            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n        },\n        'wagtailimages.filter': {\n            'Meta': {'object_name': 'Filter'},\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'spec': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})\n        },\n        'wagtailimages.image': {\n            'Meta': {'object_name': 'Image'},\n            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n            'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),\n            'focal_point_height': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'focal_point_width': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'focal_point_x': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'focal_point_y': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'height': ('django.db.models.fields.IntegerField', [], {}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),\n            'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\", 'null': 'True', 'blank': 'True'}),\n            'width': ('django.db.models.fields.IntegerField', [], {})\n        },\n        'wagtailimages.rendition': {\n            'Meta': {'unique_together': \"(('image', 'filter', 'focal_point_key'),)\", 'object_name': 'Rendition'},\n            'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),\n            'filter': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'+'\", 'to': \"orm['wagtailimages.Filter']\"}),\n            'focal_point_key': ('django.db.models.fields.CharField', [], {'default': \"''\", 'max_length': '255', 'blank': 'True'}),\n            'height': ('django.db.models.fields.IntegerField', [], {}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'image': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'renditions'\", 'to': \"orm['wagtailimages.Image']\"}),\n            'width': ('django.db.models.fields.IntegerField', [], {})\n        }\n    }\n\n    complete_apps = ['wagtailimages']", "path": "wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py"}, {"content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('wagtailimages', '0003_fix_focal_point_fields'),\n    ]\n\n    operations = [\n        migrations.AlterField(\n            model_name='rendition',\n            name='focal_point_key',\n            field=models.CharField(blank=True, default='', max_length=255, editable=False),\n        ),\n    ]\n", "path": "wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom south.utils import datetime_utils as datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n\nclass Migration(SchemaMigration):\n\n    def forwards(self, orm):\n        # remove duplicate renditions\n        db.execute(\"\"\"\n            DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (\n                SELECT image_id || '-' || filter_id FROM wagtailimages_rendition WHERE focal_point_key IS NULL GROUP BY image_id, filter_id HAVING COUNT(*) > 1\n            ) AND focal_point_key IS NULL\n        \"\"\")\n\n        # Changing field 'Rendition.focal_point_key'\n        db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, default=''))\n\n    def backwards(self, orm):\n\n        # Changing field 'Rendition.focal_point_key'\n        db.alter_column('wagtailimages_rendition', 'focal_point_key', self.gf('django.db.models.fields.CharField')(max_length=255, null=True))\n\n    models = {\n        'auth.group': {\n            'Meta': {'object_name': 'Group'},\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\n            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'})\n        },\n        'auth.permission': {\n            'Meta': {'ordering': \"('content_type__app_label', 'content_type__model', 'codename')\", 'unique_together': \"(('content_type', 'codename'),)\", 'object_name': 'Permission'},\n            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['contenttypes.ContentType']\"}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n        },\n        'auth.user': {\n            'Meta': {'object_name': 'User'},\n            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\n            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': \"'user_set'\", 'blank': 'True', 'to': \"orm['auth.Group']\"}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\n            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': \"'user_set'\", 'blank': 'True', 'to': \"orm['auth.Permission']\"}),\n            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\n        },\n        'contenttypes.contenttype': {\n            'Meta': {'ordering': \"('name',)\", 'unique_together': \"(('app_label', 'model'),)\", 'object_name': 'ContentType', 'db_table': \"'django_content_type'\"},\n            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n        },\n        'wagtailimages.filter': {\n            'Meta': {'object_name': 'Filter'},\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'spec': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'})\n        },\n        'wagtailimages.image': {\n            'Meta': {'object_name': 'Image'},\n            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n            'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),\n            'focal_point_height': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'focal_point_width': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'focal_point_x': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'focal_point_y': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),\n            'height': ('django.db.models.fields.IntegerField', [], {}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),\n            'uploaded_by_user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\", 'null': 'True', 'blank': 'True'}),\n            'width': ('django.db.models.fields.IntegerField', [], {})\n        },\n        'wagtailimages.rendition': {\n            'Meta': {'unique_together': \"(('image', 'filter', 'focal_point_key'),)\", 'object_name': 'Rendition'},\n            'file': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),\n            'filter': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'+'\", 'to': \"orm['wagtailimages.Filter']\"}),\n            'focal_point_key': ('django.db.models.fields.CharField', [], {'default': \"''\", 'max_length': '255', 'blank': 'True'}),\n            'height': ('django.db.models.fields.IntegerField', [], {}),\n            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n            'image': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'renditions'\", 'to': \"orm['wagtailimages.Image']\"}),\n            'width': ('django.db.models.fields.IntegerField', [], {})\n        }\n    }\n\n    complete_apps = ['wagtailimages']", "path": "wagtail/wagtailimages/south_migrations/0004_auto__chg_field_rendition_focal_point_key.py"}, {"content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\ndef remove_duplicate_renditions(apps, schema_editor):\n    schema_editor.execute(\"\"\"\n        DELETE FROM wagtailimages_rendition WHERE image_id || '-' || filter_id IN (\n            SELECT image_id || '-' || filter_id FROM wagtailimages_rendition WHERE focal_point_key IS NULL GROUP BY image_id, filter_id HAVING COUNT(*) > 1\n        ) AND focal_point_key IS NULL\n    \"\"\")\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('wagtailimages', '0003_fix_focal_point_fields'),\n    ]\n\n    operations = [\n        migrations.RunPython(remove_duplicate_renditions),\n        migrations.AlterField(\n            model_name='rendition',\n            name='focal_point_key',\n            field=models.CharField(blank=True, default='', max_length=255, editable=False),\n        ),\n    ]\n", "path": "wagtail/wagtailimages/migrations/0004_make_focal_point_key_not_nullable.py"}]}