Commit Graph

2 Commits (434adee9932f92a5004b4d8cebb5c9e6dcb16a73)

Author SHA1 Message Date
Your Name 434adee993 fix: merge duplicate hashtags before recollating to avoid 1062 error
The migration failed on MySQL with a 1062 duplicate-entry error: recollating
name/slug to utf8mb4_unicode_520_ci makes previously-distinct values collide
on the unique indexes, so the ALTER TABLE was rejected.

Merge colliding rows first, comparing values under the target collation. For
each collision group the lowest id is kept, references in status_hashtags,
hashtag_follows, hashtag_related and discover_category_hashtags are repointed
to it (UPDATE IGNORE + cleanup), and the losing rows are deleted before the
collation is applied. Adds a regression test for the merge path.
4 weeks ago
Your Name 88adf721c3 fix: use utf8mb4_unicode_520_ci for hashtags to fix BMP-outside collation (PR #6098)
MySQL/MariaDB's utf8mb4_unicode_ci collation treats all characters outside
the Basic Multilingual Plane as equal, conflating distinct same-length
hashtags (e.g. Shavian vs cuneiform) on the unique name/slug indexes.

Migrate the hashtags name/slug columns to utf8mb4_unicode_520_ci, which
differentiates supplementary-plane characters. Improvements over the
original PR:
- Use an explicit ALTER ... MODIFY, since Laravel's fluent ->change() emits
  no collation change on MySQL/MariaDB and silently no-ops.
- Match both 'mysql' and 'mariadb' drivers (Laravel 11+ reports MariaDB as a
  distinct driver, so a mysql-only check would skip the fix on MariaDB).
- Provide an accurate, reversible down() and preserve NOT NULL + unique keys.

Add feature tests covering the no-op path on non-MySQL drivers and, on
MySQL/MariaDB, that distinct BMP-outside hashtags coexist while same-slug
and case-insensitive dedup still work.
4 weeks ago