Skip to content
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

Handle charset that are declared per column #1881

Closed
bschmalhofer opened this issue Aug 22, 2022 · 2 comments · Fixed by #2059
Closed

Handle charset that are declared per column #1881

bschmalhofer opened this issue Aug 22, 2022 · 2 comments · Fixed by #2059
Labels
installation Concerning the installation of OTOBO
Milestone

Comments

@bschmalhofer
Copy link
Contributor

Having the charset utf8 declared on the individual columns is an interesting case.

First, let's sanity check that charset utf8 vs. utf8mb4 is really the problem. The problematic emoji is indeed encoded in four bytes:

$ uni -8 😊
😊 - U+1F60A - F0 9F 98 8A - SMILING FACE WITH SMILING EYES

So, this theory is confirmed.

I assume that you used the streamlined migration method for migrating the data from OTRS to OTOBO:
https://doc.otobo.org/manual/installation/10.0/en/content/migration-from-otrs-6.html#optional-step-streamlined-migration-of-the-database .
Checking the script scripts/backup.pl, I found that there is an oversight. The charset on the tables is adapted and the COLLATE on columns is removed in the subroutine MySQLBackupForMigrateFromOTRS(), see https://github.com/RotherOSS/otobo/blob/rel-10_1/scripts/backup.pl#L578. But the CHARACTER SET utf8 is not removed. This oversight seems to be the root cause of the problem.

Now for the fix. The statement alter table article_data_mime convert to character set utf8mb4 collate utf8mb4_general_ci; is likely not enough, as the charset set of the columns have higher priority than the default charset of the table. So the relevant statement is more like:

For each column:

ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
See https://mathiasbynens.be/notes/mysql-utf8mb4 .

My preferred solution would be to redo the migration. Either with a fixed script scripts/backup.pl or with using the standard migration method.

Originally posted by @bschmalhofer in #1879 (comment)

@bschmalhofer bschmalhofer self-assigned this Aug 22, 2022
@bschmalhofer bschmalhofer added the installation Concerning the installation of OTOBO label Aug 22, 2022
@bschmalhofer bschmalhofer added this to the OTOBO 10.0.17 milestone Aug 22, 2022
@bschmalhofer
Copy link
Contributor Author

bschmalhofer commented Aug 22, 2022

@bschmalhofer bschmalhofer removed their assignment Dec 6, 2022
dennis-dko pushed a commit that referenced this issue Dec 21, 2022
bschmalhofer added a commit that referenced this issue Dec 21, 2022
…at-are-declared-per-column

Issue #1881: Updating backup.pl to prevent own column charset and use…
@bschmalhofer
Copy link
Contributor Author

@dennis-dko made the change and tested the adapted SQL output Looks good. PR is merged. Closing.

@dennis-dko dennis-dko removed their assignment Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation Concerning the installation of OTOBO
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants