mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 01:58:44 -05:00
✨ Improve migrate-data function (file data migrations)
This will enable the ability to apply some migration to a specific file from the Server REPL.
This commit is contained in:
parent
59d0bafdc9
commit
13ca506015
2 changed files with 10 additions and 12 deletions
|
@ -10,6 +10,7 @@
|
|||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.geom.shapes.path :as gsp]
|
||||
[app.common.logging :as l]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
|
@ -21,17 +22,14 @@
|
|||
(defmulti migrate :version)
|
||||
|
||||
(defn migrate-data
|
||||
([data]
|
||||
(if (= (:version data) cp/file-version)
|
||||
([data] (migrate-data data cp/file-version))
|
||||
([data to-version]
|
||||
(if (= (:version data) to-version)
|
||||
data
|
||||
(reduce #(migrate-data %1 %2 (inc %2))
|
||||
data
|
||||
(range (:version data 0) cp/file-version))))
|
||||
|
||||
([data _ to-version]
|
||||
(-> data
|
||||
(assoc :version to-version)
|
||||
(migrate))))
|
||||
(let [migrate-fn #(do
|
||||
(l/trace :hint "migrate file" :id (:id %) :version-from %2 :version-to (inc %2))
|
||||
(migrate (assoc %1 :version (inc %2))))]
|
||||
(reduce migrate-fn data (range (:version data 0) to-version))))))
|
||||
|
||||
(defn migrate-file
|
||||
[file]
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
:components {}
|
||||
:version 7}
|
||||
|
||||
res (cpm/migrate-data data nil 8)]
|
||||
res (cpm/migrate-data data 8)]
|
||||
|
||||
;; (pprint data)
|
||||
;; (pprint res)
|
||||
|
@ -81,7 +81,7 @@
|
|||
(let [id (uuid/custom 1 2)]
|
||||
(into [] (remove #(= id %)) shapes)))))
|
||||
|
||||
res (cpm/migrate-data data nil 8)]
|
||||
res (cpm/migrate-data data 8)]
|
||||
|
||||
;; (pprint res)
|
||||
;; (pprint expect)
|
||||
|
|
Loading…
Add table
Reference in a new issue