From 1b8b9382b84e7bede0a9c091ed6b6327b77f03d3 Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Fri, 14 Jun 2024 18:06:26 +0500 Subject: [PATCH 1/4] feat!: upgrade mysql charset and collation to utf8mb4 closes #938 --- .../20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md | 1 + tutor/templates/apps/openedx/config/partials/auth.yml | 2 +- tutor/templates/k8s/deployments.yml | 4 ++-- tutor/templates/local/docker-compose.yml | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md diff --git a/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md b/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md new file mode 100644 index 0000000000..ef8e266fdc --- /dev/null +++ b/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md @@ -0,0 +1 @@ +- 💥[Feature] Upgrade default charset and collation of mysql to utf8mb4 and utf8mb4_unicode_ci respectively (by @Danyal-Faheem) \ No newline at end of file diff --git a/tutor/templates/apps/openedx/config/partials/auth.yml b/tutor/templates/apps/openedx/config/partials/auth.yml index 74d46d8b7e..56f2a8b94c 100644 --- a/tutor/templates/apps/openedx/config/partials/auth.yml +++ b/tutor/templates/apps/openedx/config/partials/auth.yml @@ -18,7 +18,7 @@ DATABASES: OPTIONS: init_command: "SET sql_mode='STRICT_TRANS_TABLES'" {%- if RUN_MYSQL %} - charset: "utf8mb3" + charset: "utf8mb4" {%- endif %} EMAIL_HOST_USER: "{{ SMTP_USERNAME }}" EMAIL_HOST_PASSWORD: "{{ SMTP_PASSWORD }}" diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index 5deaec4300..765e2be747 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -394,8 +394,8 @@ spec: image: {{ DOCKER_IMAGE_MYSQL }} args: - "mysqld" - - "--character-set-server=utf8mb3" - - "--collation-server=utf8mb3_general_ci" + - "--character-set-server=utf8mb4" + - "--collation-server=utf8mb4_general_ci" - "--binlog-expire-logs-seconds=259200" env: - name: MYSQL_ROOT_PASSWORD diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index 227f92df8f..b862dda9d4 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -41,8 +41,8 @@ services: image: {{ DOCKER_IMAGE_MYSQL }} command: > mysqld - --character-set-server=utf8mb3 - --collation-server=utf8mb3_general_ci + --character-set-server=utf8mb4 + --collation-server=utf8mb4_general_ci --binlog-expire-logs-seconds=259200 restart: unless-stopped user: "999:999" From 11e3bce57d1b63002c86c2329ffef5a9489222c3 Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Fri, 14 Jun 2024 19:57:18 +0500 Subject: [PATCH 2/4] fix: update the do sqlshell command as well --- tutor/commands/jobs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutor/commands/jobs.py b/tutor/commands/jobs.py index 93a10e5493..7510a83b31 100644 --- a/tutor/commands/jobs.py +++ b/tutor/commands/jobs.py @@ -309,7 +309,7 @@ def sqlshell(args: list[str]) -> t.Iterable[tuple[str, str]]: Extra arguments will be passed to the `mysql` command verbatim. For instance, to show tables from the "openedx" database, run `do sqlshell openedx -e 'show tables'`. """ - command = "mysql --user={{ MYSQL_ROOT_USERNAME }} --password={{ MYSQL_ROOT_PASSWORD }} --host={{ MYSQL_HOST }} --port={{ MYSQL_PORT }} --default-character-set=utf8mb3" + command = "mysql --user={{ MYSQL_ROOT_USERNAME }} --password={{ MYSQL_ROOT_PASSWORD }} --host={{ MYSQL_HOST }} --port={{ MYSQL_PORT }} --default-character-set=utf8mb4" if args: command += " " + shlex.join(args) # pylint: disable=protected-access yield ("lms", command) From 38c02a24a9cd0f6bbff0ec93dcb3d955669cdd3f Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Fri, 14 Jun 2024 19:58:09 +0500 Subject: [PATCH 3/4] docs: add note to upgrade third-party MySQL instances in changelog --- .../20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md b/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md index ef8e266fdc..660cba495d 100644 --- a/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md +++ b/changelog.d/20240614_180451_danyal.faheem_upgrade_mysql_utf8mb4.md @@ -1 +1,2 @@ -- 💥[Feature] Upgrade default charset and collation of mysql to utf8mb4 and utf8mb4_unicode_ci respectively (by @Danyal-Faheem) \ No newline at end of file +- 💥[Feature] Upgrade default charset and collation of mysql to utf8mb4 and utf8mb4_unicode_ci respectively (by @Danyal-Faheem) + This upgrade should be automatic for most users. However, if you are running a third-party MySQL (i.e., RUN_MYSQL=false), you are expected to upgrade manually. Please refer to the third-party provider's documentation for detailed upgrade instructions. Ensuring that your MySQL version is up-to-date is crucial for maintaining compatibility and security. \ No newline at end of file From 4dac5199fd334d4079ac046be7c6ea1a72fdac38 Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Tue, 25 Jun 2024 17:10:13 +0500 Subject: [PATCH 4/4] fix: replace general_ci with unicode_ci --- tutor/templates/k8s/deployments.yml | 2 +- tutor/templates/local/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tutor/templates/k8s/deployments.yml b/tutor/templates/k8s/deployments.yml index 765e2be747..ee4e9e8573 100644 --- a/tutor/templates/k8s/deployments.yml +++ b/tutor/templates/k8s/deployments.yml @@ -395,7 +395,7 @@ spec: args: - "mysqld" - "--character-set-server=utf8mb4" - - "--collation-server=utf8mb4_general_ci" + - "--collation-server=utf8mb4_unicode_ci" - "--binlog-expire-logs-seconds=259200" env: - name: MYSQL_ROOT_PASSWORD diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index b862dda9d4..aaa9601da0 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -42,7 +42,7 @@ services: command: > mysqld --character-set-server=utf8mb4 - --collation-server=utf8mb4_general_ci + --collation-server=utf8mb4_unicode_ci --binlog-expire-logs-seconds=259200 restart: unless-stopped user: "999:999"