Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix MySQL/MariaDB collation mismatch failure in v62 legacy_library_root_entity_ids migrations (#75496)

Andersonddd34b2742fb
diff --git a/resources/migrations/062/20260513_legacy_library_root_entity_ids.yaml b/resources/migrations/062/20260513_legacy_library_root_entity_ids.yaml
index b6bdbb7a0ed..a6b66ae15c5 100644
--- a/resources/migrations/062/20260513_legacy_library_root_entity_ids.yaml
+++ b/resources/migrations/062/20260513_legacy_library_root_entity_ids.yaml
@@ -3,6 +3,22 @@
databaseChangeLog:
- logicalFilePath: migrations/062_update_migrations.yaml
+ - changeSet:
+ id: v62.legacy-library-root-entity-id-old-id-cleanup
+ author: andsalves
+ comment: >-
+ Delete old changeset rows for the Library Data and Library Metrics entity ID backfills. Those changesets were
+ re-id'd after patching their MySQL/MariaDB SQL to resolve a collation mismatch issue, @see #75458.
+ changes:
+ - sql:
+ sql: >-
+ DELETE FROM ${databasechangelog.name} WHERE id IN (
+ 'v62.2026-05-13T12:00:01',
+ 'v62.2026-05-13T12:00:02'
+ ) AND filename = 'migrations/062_update_migrations.yaml';
+ rollback:
+ - empty: {}
+
- changeSet:
id: v62.2026-05-13T11:59:58
author: andsalves
@@ -55,7 +71,7 @@ databaseChangeLog:
- empty: {}
- changeSet:
- id: v62.2026-05-13T12:00:01
+ id: v62.2026-05-13T12:00:01-updated
author: andsalves
comment: Backfill canonical entity_id for legacy Library Data section
changes:
@@ -92,7 +108,7 @@ databaseChangeLog:
WHERE type = 'library-data'
AND location IN (
SELECT loc FROM (
- SELECT CONCAT('/', CAST(id AS CHAR), '/') AS loc
+ SELECT CONCAT('/', CAST(id AS CHAR), '/') COLLATE utf8mb4_unicode_ci AS loc
FROM collection
WHERE type = 'library' AND location = '/'
) lib_loc
@@ -103,7 +119,7 @@ databaseChangeLog:
FROM collection child
WHERE child.type = 'library-data'
AND child.location IN (
- SELECT CONCAT('/', CAST(lib.id AS CHAR), '/')
+ SELECT CONCAT('/', CAST(lib.id AS CHAR), '/') COLLATE utf8mb4_unicode_ci
FROM collection lib
WHERE lib.type = 'library' AND lib.location = '/'
)
@@ -113,7 +129,7 @@ databaseChangeLog:
- empty: {}
- changeSet:
- id: v62.2026-05-13T12:00:02
+ id: v62.2026-05-13T12:00:02-updated
author: andsalves
comment: Backfill canonical entity_id for legacy Library Metrics section
changes:
@@ -150,7 +166,7 @@ databaseChangeLog:
WHERE type = 'library-metrics'
AND location IN (
SELECT loc FROM (
- SELECT CONCAT('/', CAST(id AS CHAR), '/') AS loc
+ SELECT CONCAT('/', CAST(id AS CHAR), '/') COLLATE utf8mb4_unicode_ci AS loc
FROM collection
WHERE type = 'library' AND location = '/'
) lib_loc
@@ -161,7 +177,7 @@ databaseChangeLog:
FROM collection child
WHERE child.type = 'library-metrics'
AND child.location IN (
- SELECT CONCAT('/', CAST(lib.id AS CHAR), '/')
+ SELECT CONCAT('/', CAST(lib.id AS CHAR), '/') COLLATE utf8mb4_unicode_ci
FROM collection lib
WHERE lib.type = 'library' AND lib.location = '/'
)
diff --git a/test/metabase/app_db/schema_migrations_test.clj b/test/metabase/app_db/schema_migrations_test.clj
index d4e7f5228d6..c71f4e25566 100644
--- a/test/metabase/app_db/schema_migrations_test.clj
+++ b/test/metabase/app_db/schema_migrations_test.clj
@@ -2893,8 +2893,8 @@
(str/trim (t2/select-one-fn :entity_id :collection :id collection-id)))
(deftest backfill-legacy-library-root-collection-entity-ids-test
- (testing "v62.2026-05-13T12:00:00 through v62.2026-05-13T12:00:02: backfill canonical Library root entity IDs"
- (impl/test-migrations ["v62.2026-05-13T12:00:00" "v62.2026-05-13T12:00:02"] [migrate!]
+ (testing "v62.2026-05-13T12:00:00 through v62.2026-05-13T12:00:02-updated: backfill canonical Library root entity IDs"
+ (impl/test-migrations ["v62.2026-05-13T12:00:00" "v62.2026-05-13T12:00:02-updated"] [migrate!]
(let [library-id (insert-legacy-library-collection! {:name "Library"
:slug "library"
:type "library"
@@ -2919,7 +2919,7 @@
(deftest backfill-legacy-library-root-collection-entity-ids-test-2
(testing "ambiguous Library Data direct children are not modified"
- (impl/test-migrations ["v62.2026-05-13T12:00:00" "v62.2026-05-13T12:00:02"] [migrate!]
+ (impl/test-migrations ["v62.2026-05-13T12:00:00" "v62.2026-05-13T12:00:02-updated"] [migrate!]
(let [library-id (insert-legacy-library-collection! {:name "Library"
:slug "library"
:type "library"
@@ -2951,7 +2951,7 @@
(deftest backfill-legacy-library-root-collection-entity-ids-test-3
(testing "Library Data collections outside Library root do not count as ambiguous"
- (impl/test-migrations ["v62.2026-05-13T12:00:00" "v62.2026-05-13T12:00:02"] [migrate!]
+ (impl/test-migrations ["v62.2026-05-13T12:00:00" "v62.2026-05-13T12:00:02-updated"] [migrate!]
(let [library-id (insert-legacy-library-collection! {:name "Library"
:slug "library"
:type "library"
@@ -2979,7 +2979,7 @@
(deftest backfill-legacy-library-root-collection-entity-ids-test-4
(testing "pre-existing canonical Library rows with missing types prevent entity_id collisions"
- (impl/test-migrations ["v62.2026-05-13T11:59:58" "v62.2026-05-13T12:00:02"] [migrate!]
+ (impl/test-migrations ["v62.2026-05-13T11:59:58" "v62.2026-05-13T12:00:02-updated"] [migrate!]
(let [canonical-library-id (insert-legacy-library-collection! {:name "Pre-existing canonical Library"
:slug "canonical-library"
:type nil