From 013357c4d166aed56580be5e76fc9f9f8ec9538e Mon Sep 17 00:00:00 2001 From: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com> Date: Sat, 21 Nov 2026 02:33:32 +0800 Subject: [PATCH] fix(migrations): make 038 run on utf8mb4_unicode_ci schemas compose.yaml starts MySQL with --collation-server=utf8mb4_unicode_ci, so generic_templates.id is utf8mb4_unicode_ci, while JSON_TABLE returns its string columns with the server default utf8mb4_0900_ai_ci. The join in 038 compares the two directly and aborts the whole script with ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operation '=' so the documented upgrade step leaves every row unchanged on Compose. Compare both sides of the join under one explicit collation, which works on schemas that inherited either collation. --- migrations/038_generic_sop_host_credentials.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migrations/038_generic_sop_host_credentials.sql b/migrations/038_generic_sop_host_credentials.sql index f5382932f..a3718818b 100644 --- a/migrations/038_generic_sop_host_credentials.sql +++ b/migrations/038_generic_sop_host_credentials.sql @@ -1,5 +1,11 @@ -- Run after 033_generic_sop_mr_node.sql and the Git credential cutover. -- Replace the shipped authentication instruction in the built-in MR roles. +-- +-- JSON_TABLE returns its string columns with the server's default collation +-- (utf8mb4_0900_ai_ci on MySQL 8), while a schema created by compose.yaml uses +-- utf8mb4_unicode_ci. Comparing the two directly fails with +-- "Illegal mix of collations ... for operation '='" (ERROR 1267) on Compose +-- deployments, so the join compares both sides under one explicit collation. SET NAMES utf8mb4; SET @old_mr_auth = 'GitHub 仓库优先用已配置的 GitHub MCP,没有时用 curl 调 GitHub API,令牌取 $AGENTFLOW_GIT_TOKEN;其它托管平台用已配置的对应 MCP。'; @@ -10,7 +16,7 @@ JOIN JSON_TABLE(t.payload, '$.Agents[*]' COLUMNS ( agent_order FOR ORDINALITY, agent_id VARCHAR(64) PATH '$.id', agent_prompt TEXT PATH '$.prompt' -)) a ON a.agent_id = CONCAT(t.id, '-mr') +)) a ON a.agent_id COLLATE utf8mb4_unicode_ci = CONCAT(t.id, '-mr') COLLATE utf8mb4_unicode_ci SET t.payload = JSON_SET(t.payload, CONCAT('$.Agents[', a.agent_order - 1, '].prompt'), REPLACE(a.agent_prompt, @old_mr_auth, @new_mr_auth)), t.updated_at = UTC_TIMESTAMP()