mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix migration and repair for nil ids
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user