The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Move glossary `entity_id` migration from v65 to v64 for backport (#82776)
Tyler Plude9d1c919f6b6e
diff --git a/resources/migrations/065/20260911_glossary_entity_id.yaml b/resources/migrations/064/20260911_glossary_entity_id.yamlsimilarity index 61%rename from resources/migrations/065/20260911_glossary_entity_id.yamlrename to resources/migrations/064/20260911_glossary_entity_id.yamlindex 29773de7dde..735fe9d0339 100644--- a/resources/migrations/065/20260911_glossary_entity_id.yaml+++ b/resources/migrations/064/20260911_glossary_entity_id.yaml@@ -1,12 +1,22 @@## Glossary entries get an entity_id so serialization and remote sync can key them on a stable, portable## identifier instead of the (renameable, per-instance) term. Backfill mirrors 20260723_backfill_entity_ids:## all three dialect variants in one changeset so every database records it, then NOT NULL and UNIQUE.+##+## These changesets first shipped on master as v65.* in migrations/065/. They were moved here to backport the+## feature to v64, so each one is skipped (MARK_RAN) on a database that already ran its v65 counterpart.databaseChangeLog:- changeSet:- id: v65.2026-09-11T12:00:00+ id: v64.2026-09-11T12:00:00author: tpludecomment: Add entity_id column to glossary table+ preConditions:+ - onFail: MARK_RAN+ - not:+ changeSetExecuted:+ id: v65.2026-09-11T12:00:00+ author: tplude+ changeLogFile: migrations/065/20260911_glossary_entity_id.yamlchanges:- addColumn:tableName: glossary@@ -23,9 +33,16 @@ databaseChangeLog:columnName: entity_id- changeSet:- id: v65.2026-09-11T12:00:01+ id: v64.2026-09-11T12:00:01author: tpludecomment: Backfill NULL glossary.entity_id values+ preConditions:+ - onFail: MARK_RAN+ - not:+ changeSetExecuted:+ id: v65.2026-09-11T12:00:01+ author: tplude+ changeLogFile: migrations/065/20260911_glossary_entity_id.yamlchanges:- sql:dbms: postgresql@@ -39,9 +56,16 @@ databaseChangeLog:rollback: []- changeSet:- id: v65.2026-09-11T12:00:02+ id: v64.2026-09-11T12:00:02author: tpludecomment: entity_id is NOT NULL on glossary+ preConditions:+ - onFail: MARK_RAN+ - not:+ changeSetExecuted:+ id: v65.2026-09-11T12:00:02+ author: tplude+ changeLogFile: migrations/065/20260911_glossary_entity_id.yamlchanges:- addNotNullConstraint:tableName: glossary@@ -49,9 +73,16 @@ databaseChangeLog:columnDataType: char(21)- changeSet:- id: v65.2026-09-11T12:00:03+ id: v64.2026-09-11T12:00:03author: tpludecomment: entity_id is unique on glossary+ preConditions:+ - onFail: MARK_RAN+ - not:+ changeSetExecuted:+ id: v65.2026-09-11T12:00:03+ author: tplude+ changeLogFile: migrations/065/20260911_glossary_entity_id.yamlchanges:- addUniqueConstraint:tableName: glossarydiff --git a/test/metabase/app_db/schema_migrations_test.clj b/test/metabase/app_db/schema_migrations_test.cljindex 185faaece2c..7b8f8834161 100644--- a/test/metabase/app_db/schema_migrations_test.clj+++ b/test/metabase/app_db/schema_migrations_test.clj@@ -3408,8 +3408,8 @@(t2/select-one :metabase_field_user_settings :field_id mixed-id))))))))(deftest glossary-entity-id-backfill-test- (testing "v65.2026-09-11: glossary.entity_id is added, backfilled for existing rows, NOT NULL and unique"- (impl/test-migrations ["v65.2026-09-11T12:00:00" "v65.2026-09-11T12:00:03"] [migrate!]+ (testing "v64.2026-09-11: glossary.entity_id is added, backfilled for existing rows, NOT NULL and unique"+ (impl/test-migrations ["v64.2026-09-11T12:00:00" "v64.2026-09-11T12:00:03"] [migrate!](let [row (fn [term] {:term term:definition (str term " definition"):creator_id 13371338@@ -3430,3 +3430,31 @@(testing "entity_id is unique"(is (thrown? Exception(t2/insert! :glossary (assoc (row "NRR") :entity_id arr-eid))))))))))++(deftest glossary-entity-id-skipped-when-v65-ids-ran-test+ (testing "v64.2026-09-11 glossary changesets are MARK_RAN on a database that already ran them under their v65 ids"+ (impl/test-migrations ["v64.2026-09-11T12:00:00" "v64.2026-09-11T12:00:03"] [migrate!]+ (let [clog (keyword (liquibase/changelog-table-name (mdb/data-source)))+ last-order (:orderexecuted (t2/select-one clog {:order-by [[:orderexecuted :desc]]}))+ suffixes ["T12:00:00" "T12:00:01" "T12:00:02" "T12:00:03"]]+ (t2/insert! clog (map-indexed (fn [i suffix]+ {:id (str "v65.2026-09-11" suffix)+ :author "tplude"+ :filename "migrations/065/20260911_glossary_entity_id.yaml"+ :dateexecuted :%now+ :orderexecuted (+ last-order i 1)+ :exectype "EXECUTED"})+ suffixes))+ ;; Liquibase caches the ran-changeset list per connection; drop it so the precondition sees the rows above.+ (.resetAll (liquibase.changelog.ChangeLogHistoryServiceFactory/getInstance))+ (migrate!)+ (is (= (repeat 4 "MARK_RAN")+ (map #(t2/select-one-fn :exectype clog :id (str "v64.2026-09-11" %)) suffixes)))+ (testing "the changes were skipped, not re-applied"+ ;; information_schema spans every database on a shared MySQL server, so scope to this app db's schema+ (is (empty? (t2/query [(str "SELECT column_name FROM information_schema.columns"+ " WHERE lower(table_name) = 'glossary' AND lower(column_name) = 'entity_id'"+ (case (mdb/db-type)+ :mysql " AND table_schema = database()"+ :postgres " AND table_schema = current_schema()"+ :h2 ""))]))))))))