mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 00:58:26 -05:00
🐛 Add data migration for ensure proper types on group like shapes.
Becuse of a bug, the `:shapes` attribute on group like objects had become to seq when they should be a vector. The real fix is already in other commit. This commit adds a migration for address the old data already stored in the database.
This commit is contained in:
parent
24f0a3945d
commit
1ffdb41cfc
2 changed files with 16 additions and 19 deletions
|
@ -20,7 +20,7 @@
|
|||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]))
|
||||
|
||||
(def file-version 1)
|
||||
(def file-version 2)
|
||||
(def max-safe-int 9007199254740991)
|
||||
(def min-safe-int -9007199254740991)
|
||||
|
||||
|
@ -268,7 +268,7 @@
|
|||
(s/every :internal.shape/point :kind vector?))
|
||||
|
||||
(s/def :internal.shape/shapes
|
||||
(s/every uuid?))
|
||||
(s/every uuid? :kind vector?))
|
||||
|
||||
(s/def ::shape-attrs
|
||||
(s/keys :opt-un [:internal.shape/blocked
|
||||
|
@ -295,7 +295,7 @@
|
|||
:internal.shape/x
|
||||
:internal.shape/y
|
||||
:internal.shape/exports
|
||||
;; :internal.shape/shapes
|
||||
:internal.shape/shapes
|
||||
:internal.shape/stroke-color
|
||||
:internal.shape/stroke-color-ref-file
|
||||
:internal.shape/stroke-color-ref-id
|
||||
|
|
|
@ -34,21 +34,18 @@
|
|||
|
||||
;; -- MIGRATIONS --
|
||||
|
||||
(defn- generate-child-parent-index
|
||||
[objects]
|
||||
(reduce-kv
|
||||
(fn [index id obj]
|
||||
(into index (map #(vector % id) (:shapes obj []))))
|
||||
{} objects))
|
||||
;; Ensure that all :shape attributes on shapes are vectors.
|
||||
|
||||
;; (defmethod migrate 5
|
||||
;; [data]
|
||||
;; (update data :objects
|
||||
;; (fn [objects]
|
||||
;; (let [index (generate-child-parent-index objects)]
|
||||
;; (d/mapm
|
||||
;; (fn [id obj]
|
||||
;; (let [parent-id (get index id)]
|
||||
;; (assoc obj :parent-id parent-id)))
|
||||
;; objects)))))
|
||||
(defmethod migrate 2
|
||||
[data]
|
||||
(letfn [(update-object [id object]
|
||||
(d/update-when object :shapes
|
||||
(fn [shapes]
|
||||
(if (seq? shapes)
|
||||
(into [] shapes)
|
||||
shapes))))
|
||||
|
||||
(update-page [id page]
|
||||
(update page :objects #(d/mapm update-object %)))]
|
||||
|
||||
(update data :pages-index #(d/mapm update-page %))))
|
||||
|
|
Loading…
Add table
Reference in a new issue