Reduce focal_point_key max_length to 16

pull/3300/head
Matt Westcott 2017-01-17 19:19:42 +00:00
rodzic c0cd53918e
commit 25f57d0636
5 zmienionych plików z 55 dodań i 3 usunięć

Wyświetl plik

@ -63,7 +63,7 @@ class Migration(migrations.Migration):
('file', models.ImageField(width_field='width', upload_to='images', height_field='height')),
('width', models.IntegerField(editable=False)),
('height', models.IntegerField(editable=False)),
('focal_point_key', models.CharField(editable=False, max_length=255, null=True)),
('focal_point_key', models.CharField(editable=False, max_length=16, null=True)),
('filter', models.ForeignKey(on_delete=models.CASCADE, related_name='+', to='wagtailimages.Filter')),
('image', models.ForeignKey(on_delete=models.CASCADE, related_name='renditions', to='wagtailimages.Image')),
],

Wyświetl plik

@ -44,6 +44,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='rendition',
name='focal_point_key',
field=models.CharField(blank=True, default='', max_length=255, editable=False),
field=models.CharField(blank=True, default='', max_length=16, editable=False),
),
]

Wyświetl plik

@ -17,6 +17,34 @@ class Migration(migrations.Migration):
name='filter_spec',
field=models.CharField(db_index=True, max_length=255),
),
# New step introduced in Wagtail 1.8.1:
#
# Reduce max_length of rendition.focal_point_key to 16, from the previous value of 255
# which existed on Wagtail <= 1.8. MySQL has a limit of 767 (on InnoDB) or 1000 (on MyISAM)
# bytes; depending on the character encoding used, this limit may be reached by the
# original index on ['image', 'filter', 'focal_point_key'] (= 1 varchar and two FKs)
# or the new index on ['image', 'filter_spec', 'focal_point_key'] (= 2 varchars and one FK).
#
# To mitigate this, we reduce focal_point_key in the following places:
# * Retrospectively in the original migration, so that configurations that previously
# failed on wagtailimages/0001_initial can now run (see #2925 / #2953);
# * Here, so that previously-working Wagtail <=1.7 installations that failed on the
# AlterUniqueTogether below when upgrading to 1.8 can now succeed;
# * In the newly-added migration wagtailimages/0017, so that existing Wagtail 1.8 installations
# that successfully applied the old 1.8 version of this migration are consistent with
# other setups.
#
# Projects with a custom image model don't have to worry about this - they'll have an existing
# migration with the max_length=255, and will get a new migration reducing it to max_length=16
# the next time they run makemigrations.
migrations.AlterField(
model_name='rendition',
name='focal_point_key',
field=models.CharField(blank=True, default='', max_length=16, editable=False),
),
migrations.AlterUniqueTogether(
name='rendition',
unique_together=set([('image', 'filter_spec', 'focal_point_key')]),

Wyświetl plik

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wagtailimages', '0016_deprecate_rendition_filter_relation'),
]
operations = [
# The Wagtail 1.8 version of migration wagtailimages/0016 did not include the
# step to reduce focal_point_key's max_length to 16, necessary to make it work
# on some MySQL configurations. This migration serves only to ensure that
# installations upgrading from 1.8 to >=1.8.1 have this change applied; on other
# setups (where the current 0016 and 0017 are applied together), this is a no-op.
migrations.AlterField(
model_name='rendition',
name='focal_point_key',
field=models.CharField(blank=True, default='', max_length=16, editable=False),
),
]

Wyświetl plik

@ -493,7 +493,7 @@ class AbstractRendition(models.Model):
file = models.ImageField(upload_to=get_rendition_upload_to, width_field='width', height_field='height')
width = models.IntegerField(editable=False)
height = models.IntegerField(editable=False)
focal_point_key = models.CharField(max_length=255, blank=True, default='', editable=False)
focal_point_key = models.CharField(max_length=16, blank=True, default='', editable=False)
@property
def url(self):