Skip to content

Fix database collation for utf8mb4_unicode_ci columns#229

Merged
projectedanx merged 2 commits into
masterfrom
jules-3193185667911188223-c6fef215
Jun 6, 2026
Merged

Fix database collation for utf8mb4_unicode_ci columns#229
projectedanx merged 2 commits into
masterfrom
jules-3193185667911188223-c6fef215

Conversation

@projectedanx

Copy link
Copy Markdown
Owner

The previous implementation converted all columns to utf8mb4_bin, which wiped the required utf8mb4_unicode_ci collations on columns like title and ip. This fix updates yourls_upgrade_505_to_506 and yourls_upgrade_to_506 to restore utf8mb4_unicode_ci for the title and ip columns exactly after applying the global utf8mb4_bin conversion, effectively targeting keyword and url.


PR created automatically by Jules for task 3193185667911188223 started by @projectedanx

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the database upgrade queries in includes/functions-upgrade.php for version 5.0.6, converting the URL table to utf8mb4_bin and adjusting the collations of the title and ip columns. A critical issue was identified where removing the explicit column change for keyword in the upgrade path from older versions prevents reducing its length from VARCHAR(200) to VARCHAR(100). This can trigger index key length limit errors on certain MySQL/MariaDB configurations and cause schema inconsistency. It is recommended to restore the explicit change clause for the keyword column as suggested.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +146 to +148
"CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin, " .
"CHANGE `title` `title` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, " .
"CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",
"CHANGE `ip` `ip` VARCHAR(41) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

By removing the explicit CHANGE clause for the keyword column, this upgrade path will fail to reduce the keyword column length from VARCHAR(200) to VARCHAR(100) when upgrading from versions prior to 505.

In MySQL/MariaDB, a VARCHAR(200) column using utf8mb4 as a primary key exceeds the default 767-byte index key length limit (200 * 4 = 800 bytes). This will cause the upgrade to fail with a Specified key was too long; max key length is 767 bytes error on standard/older database configurations. Additionally, it leads to schema inconsistency between new installations (which use VARCHAR(100)) and upgraded installations.

We should restore the explicit CHANGE clause for keyword to safely reduce its length to 100 during the table conversion.

            "CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin, " .
            "CHANGE `keyword` `keyword` VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '', " .
            "CHANGE `title` `title` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, " .
            "CHANGE `ip` `ip` VARCHAR(41) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;"

@projectedanx projectedanx merged commit f0ed8b0 into master Jun 6, 2026
15 of 16 checks passed
@projectedanx projectedanx deleted the jules-3193185667911188223-c6fef215 branch June 6, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant