SmileyChris / easy-thumbnails

Easy thumbnails for Django

Home Page:http://easy-thumbnails.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Increase File name field length

petrklus opened this issue · comments

For our use-case, we have found that the 255 character limit is not enough to contain large file names + thumbnail prefix folder structure.

I therefore suggest increasing the limit here:

https://github.com/SmileyChris/easy-thumbnails/blob/master/easy_thumbnails/models.py#L55

We have temporarily mitigated the issue with a migration patching the table directly, though it would be great to have a permanent solution.

I think that 4096 should be enough to contain even the longest prefixes alongside the 255/7 file name length max.

from django.db import migrations

class Migration(migrations.Migration):

    dependencies = [
        ...
    ]

    operations = [
        migrations.RunSQL(
            "ALTER TABLE easy_thumbnails_thumbnail ALTER COLUMN name TYPE varchar(4096);"),
        migrations.RunSQL(
            "ALTER TABLE easy_thumbnails_source ALTER COLUMN name TYPE varchar(4096);")
    ]

@SmileyChris / @jrief any thoughts on this?