django-mysql icon indicating copy to clipboard operation
django-mysql copied to clipboard

charset + collation transformer (fix utf8mb4)

Open adamchainz opened this issue 9 years ago • 7 comments

Add a command that does ALTER DATABASE, and ALTER TABLE as required to change character set for the database from utf8 to utf8mb4, or rather, from any arbitrary charset + collation to any other.

Don't forget to remove the note in the checks docs about this being WIP.

adamchainz avatar Feb 01 '16 19:02 adamchainz

@adamchainz: I've put together a management command for this that I'm currently testing internally. This isn't a "help wanted" ticket, so I thought I'd check if you were interested in it before submitting a PR.

cassiemeharry avatar Aug 25 '16 22:08 cassiemeharry

Yes please send a PR! The tags are only loose and not up to date. Just beware I won't be able to review it for a couple weeks though.

On Thursday, 25 August 2016, Nick Meharry [email protected] wrote:

@adamchainz https://github.com/adamchainz: I've put together a management command for this that I'm currently testing internally. This isn't a "help wanted" ticket, so I thought I'd check if you were interested in it before submitting a PR.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adamchainz/django-mysql/issues/216#issuecomment-242557549, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0WCfrl0LW_IUaAI2zooMaPjsL9jgk4ks5qjhF4gaJpZM4HQ0pS .

Adam

adamchainz avatar Aug 26 '16 07:08 adamchainz

Hi

Such a management command would be really great to have ! @nickmeharry are you still considering submitting a PR with this ?

thomasfillon avatar Apr 10 '17 13:04 thomasfillon

@thomasfillon This had moved to the back burner for me, but I should have that command sitting around here somewhere. Last I recall, I got stuck on dealing with indexes becoming too long after changing the byte size of CharField columns. I'll poke at it again this week.

cassiemeharry avatar Apr 10 '17 18:04 cassiemeharry

@nickmeharry Ok great ! Thank you .

thomasfillon avatar Apr 12 '17 07:04 thomasfillon

See also https://code.djangoproject.com/ticket/18392

The index length problem you mention seems to describe there:

"InnoDB has a maximum index length of 767 bytes, so for utf8 or utf8mb4 columns, you can index a maximum of 255 or 191 characters, respectively. If you currently have utf8 columns with indexes longer than 191 characters, you will need to index a smaller number of characters.

thomasfillon avatar Apr 12 '17 08:04 thomasfillon

I've cleaned up my management command and submitted a pull request: #356

cassiemeharry avatar Apr 25 '17 23:04 cassiemeharry

Not gonna do this.

adamchainz avatar Oct 19 '22 07:10 adamchainz

@adamchainz Hi Adam! Can you elaborate on why this change was closed? Are there plans to support such command in the future?

It's a valid case that I'm currently researching and the command is exactly what I need.

gstamenov avatar Nov 16 '22 14:11 gstamenov

See #959

adamchainz avatar Nov 16 '22 14:11 adamchainz