♻️ Add minor refactor to file migrations

Relevant changes:

- Add the ability to create migration in both directions, defaulting
  to identity if not provided
- Move the version attribute to file table column for to make it more
  accessible (previously it was on data blob)
- Reduce db update operations on file-update rpc method
This commit is contained in:
Andrey Antukh 2024-02-14 11:37:27 +01:00
parent 7ac4b89a0e
commit b718a282e0
16 changed files with 240 additions and 151 deletions

View file

@ -1496,6 +1496,13 @@
fdata (migrate-graphics fdata)]
(update fdata :options assoc :components-v2 true)))))
(defn- fix-version
[file]
(let [file (fmg/fix-version file)]
(if (> (:version file) 22)
(assoc file :version 22)
file)))
(defn- get-file
[system id]
(binding [pmap/*load-fn* (partial fdata/load-pointer system id)]
@ -1506,10 +1513,7 @@
(update :data assoc :id id)
(update :data fdata/process-pointers deref)
(update :data fdata/process-objects (partial into {}))
(update :data (fn [data]
(if (> (:version data) 22)
(assoc data :version 22)
data)))
(fix-version)
(fmg/migrate-file))))
(defn get-team