Skip to content

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

fix: handle special cased migration (#62110)

Edward Pagetb44c4d3c8e5d
diff --git a/src/metabase/app_db/liquibase.clj b/src/metabase/app_db/liquibase.clj
index b1033e74112..58e4f504a23 100644
--- a/src/metabase/app_db/liquibase.clj
+++ b/src/metabase/app_db/liquibase.clj
@@ -478,10 +478,22 @@
"v45.00-001" legacy-migrations-file
"v56.0000-00-00T00:00:00" update001-migrations-file]))))))
+(def ^:private special-case-migrations #{"v56.2025-06-05T16:48:48" "v56.2025-05-19T16:48:48"})
+
+(defn- handle-special-case-migrations
+ "This handles v56 migrations that were checked into the v55 branch to resolve an issue with
+ inadventently backported migrations in 55. We check if this or the bad backports are the most recent
+ available migration and explicitly return 55 as the available major version if so."
+ [s]
+ (when (contains? special-case-migrations s)
+ 55))
+
(defn- extract-numbers
"Returns contiguous integers parsed from string s"
[s]
- (map #(Integer/parseInt %) (re-seq #"\d+" s)))
+ (if-let [special-cased (handle-special-case-migrations s)]
+ [special-cased]
+ (map #(Integer/parseInt %) (re-seq #"\d+" s))))
(defn latest-available-major-version
"Get the latest version that Liquibase would apply if we ran migrations right now."
diff --git a/test/metabase/app_db/liquibase_test.clj b/test/metabase/app_db/liquibase_test.clj
index 8ff637ac076..18d56033ebf 100644
--- a/test/metabase/app_db/liquibase_test.clj
+++ b/test/metabase/app_db/liquibase_test.clj
@@ -153,6 +153,11 @@
(.update liquibase "")
(is (< 52 (liquibase/latest-applied-major-version conn (.getDatabase liquibase))))))))
+(deftest extract-numbers-special-case-test
+ (testing "when specific migration verison is passed reports different major version"
+ (is (= 55 (first (#'liquibase/extract-numbers "v56.2025-06-05T16:48:48"))))
+ (is (= 55 (first (#'liquibase/extract-numbers "v56.2025-05-19T16:48:48"))))))
+
(deftest rollback-major-version
(mt/test-drivers #{:h2 :mysql :rollback}
(mt/with-temp-empty-app-db [conn driver/*driver*]