New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify all models + migrations to have stripe_id
be VARCHAR(191)
#350
Conversation
For databases with character encodings with bytes-per-char larger than utf8, 255 is too large a VARCHAR length for the 1000 byte limit MySQL imposes on keys. Reducing this to 191 allows the `stripe_id` field to be a unique key in utf8mb4, a common upgrade to utf8 that has more bytes-per-char.
This also Closes #273. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @paltman
@brosner I'd love to hear your thoughts on this. |
What's the status on this? |
@paltman can this now be merged? |
@brosner cool. I'll I'll merge it. Should this be considered BIC? What will happen when people upgrade and there are changes to migrations that are already applied? |
Thank you for your patience @ahubers as well as your contribution. |
@paltman when can we expect this to be released? |
@tstirrat15 we are close. I'm finishing up some documentation and I think there's an issue that needs tests before he pushes a new release. Most of the work on the current milestone is done. |
The migration will already exist in their |
Motivation
The max length for a key field in MySQL is 767 Bytes. A
VARCHAR(255)
in utf8 does not exceed that limit, however it does with bulkier encodings like utf8mb4. These encodings are becoming more common as they support emojis.Reducing the
stripe_id
field toVARCHAR(191)
keeps us from hitting that limit.For some context on the issue I'm having, trying to run pinax-stripe migrations on our django instance is resulting in the following OperationalError:
Additional Info
The Motivation section above is informed entirely by https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes.
But Alex, you modified a migration? Isn't that bad?
Patching the migration with a new one would still result in the same failure I show above because it will still try to create the tables with the
VARCHAR(255)
keys. I don't see a problem with modifying these because I don't see stripe IDs ever having a length > 191. So this shouldn't affect any clients' tables.For those already using pinax-stripe in production environments, they won't notice any difference -- for those trying to get it started in their own environment, they shouldn't run into this problem now...