From 59f7ede4ff34c83271edcfbf1215a4ac525c4dd3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 23 Sep 2025 09:57:38 +0200 Subject: [PATCH] :bug: Add migration for properly decode all position data on text shapes --- backend/dev/user.clj | 7 ++++--- common/src/app/common/files/migrations.cljc | 23 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backend/dev/user.clj b/backend/dev/user.clj index 522b5ae643..04040776ef 100644 --- a/backend/dev/user.clj +++ b/backend/dev/user.clj @@ -6,22 +6,24 @@ (ns user (:require + [app.binfile.common :as bfc] [app.common.data :as d] [app.common.debug :as debug] [app.common.exceptions :as ex] [app.common.files.helpers :as cfh] [app.common.fressian :as fres] [app.common.geom.matrix :as gmt] + [app.common.json :as json] [app.common.logging :as l] [app.common.perf :as perf] [app.common.pprint :as pp] [app.common.schema :as sm] [app.common.schema.desc-js-like :as smdj] [app.common.schema.desc-native :as smdn] - [app.common.schema.openapi :as oapi] [app.common.schema.generators :as sg] + [app.common.schema.openapi :as oapi] [app.common.spec :as us] - [app.common.json :as json] + [app.common.time :as ct] [app.common.transit :as t] [app.common.types.file :as ctf] [app.common.uuid :as uuid] @@ -31,7 +33,6 @@ [app.srepl.helpers :as srepl.helpers] [app.srepl.main :as srepl] [app.util.blob :as blob] - [app.common.time :as ct] [clj-async-profiler.core :as prof] [clojure.contrib.humanize :as hum] [clojure.java.io :as io] diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 2284f95e45..f368db6069 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -31,6 +31,7 @@ [app.common.types.shape :as cts] [app.common.types.shape.interactions :as ctsi] [app.common.types.shape.shadow :as ctss] + [app.common.types.shape.text :as ctst] [app.common.types.text :as types.text] [app.common.uuid :as uuid] [clojure.set :as set] @@ -1585,6 +1586,25 @@ (-> data (update :pages-index d/update-vals update-page)))) +(defmethod migrate-data "0012-fix-position-data" + [data _] + (let [decode-fn + (sm/decoder ctst/schema:position-data sm/json-transformer) + + update-object + (fn [object] + (if (cfh/text-shape? object) + (d/update-when object :position-data decode-fn) + object)) + + update-container + (fn [container] + (d/update-when container :objects d/update-vals update-object))] + + (-> data + (update :pages-index d/update-vals update-container) + (d/update-when :components d/update-vals update-container)))) + (def available-migrations (into (d/ordered-set) ["legacy-2" @@ -1652,4 +1672,5 @@ "0009-clean-library-colors" "0009-add-partial-text-touched-flags" "0010-fix-swap-slots-pointing-non-existent-shapes" - "0011-fix-invalid-text-touched-flags"])) + "0011-fix-invalid-text-touched-flags" + "0012-fix-position-data"]))