🐛 Fix migration and repair for nil ids

This commit is contained in:
Pablo Alba
2025-12-11 17:10:09 +01:00
parent c2ace7c529
commit 58b298b3e0
2 changed files with 26 additions and 7 deletions

View File

@@ -1775,7 +1775,7 @@
(contains? component :objects))
(dissoc component :objects)
component))]
(d/update-when data :components check-component)))
(d/update-when data :components d/update-vals check-component)))
(defmethod migrate-data "0018-sync-component-id-with-near-main"
[data _]
@@ -1788,9 +1788,18 @@
(if (and (some? ref-shape)
(or (not= (:component-id shape) (:component-id ref-shape))
(not= (:component-file shape) (:component-file ref-shape))))
(assoc shape
:component-id (:component-id ref-shape)
:component-file (:component-file ref-shape))
(cond-> shape
(some? (:component-id ref-shape))
(assoc :component-id (:component-id ref-shape))
(nil? (:component-id ref-shape))
(dissoc :component-id)
(some? (:component-file ref-shape))
(assoc :component-file (:component-file ref-shape))
(nil? (:component-file ref-shape))
(dissoc :component-file))
shape))
shape))
@@ -1799,6 +1808,7 @@
(-> data
(update :pages-index d/update-vals update-page))))
(def available-migrations
(into (d/ordered-set)
["legacy-2"

View File

@@ -340,9 +340,18 @@
; Set the component-id and component-file to the ones of the near main
(log/debug :hint (str " -> set component-id to " (:component-id args)))
(log/debug :hint (str " -> set component-file to " (:component-file args)))
(assoc shape
:component-id (:component-id args)
:component-file (:component-file args)))]
(cond-> shape
(some? (:component-id args))
(assoc :component-id (:component-id args))
(nil? (:component-id args))
(dissoc :component-id)
(some? (:component-file args))
(assoc :component-file (:component-file args))
(nil? (:component-file args))
(dissoc :component-file)))]
(log/dbg :hint "repairing shape :component-id-mismatch" :id (:id shape) :name (:name shape) :page-id page-id)
(-> (pcb/empty-changes nil page-id)