specifying character set for fields

14 views
Skip to first unread message

Pas

unread,
Oct 14, 2014, 7:01:09 AM10/14/14
to south...@googlegroups.com
Hello!

I'm trying to deploy an application that uses Django and Celery, and sure works fine with postgres, but there's already a mysql 5.5.38 on the server, so things went south from this, however, it works with a minor edit in djcelery's model.

The infamous key too long problem[1] when the column uses a multibyte encoding (inherited from the default utf8mb4 that was set with CREATE DATABASE <name> CHARACTER SET utf8mb4, and the table defaults to InnoDB, so 767/4 ~ 191 chars max, whereas 255 is specified in the migration). Now, simply decreasing the allowed column length works, but MySQL allows (and InnoDB supports, or just doesn't care what the bytes represent and how) specifying per-column the character set to use, but haven't found any information on how best one could do this with South. (Because just setting that field to ASCII would solve the problem, as celery is unlikely to generate UTF8 task IDs.)

So, I'd like to get some information on this.

Thanks,
Pas

[1] http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes

Andrew Godwin

unread,
Oct 14, 2014, 12:56:41 PM10/14/14
to south...@googlegroups.com
Hi Pas,

In South, your only real option is to either make a custom field that changes the value of db_type to include the charset in a way that will work, or write raw SQL using the db.execute() command to add the column manually. There's no built-in Django way to do it, unfortunately.

Andrew

--
You received this message because you are subscribed to the Google Groups "South Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to south-users...@googlegroups.com.
To post to this group, send email to south...@googlegroups.com.
Visit this group at http://groups.google.com/group/south-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages