Merge branch 'feat/db' into refactor/single-block-type

This commit is contained in:
Tienson Qin
2024-08-03 15:34:40 +08:00
56 changed files with 491 additions and 508 deletions

View File

@@ -43,6 +43,26 @@
[{:db/id (:db/id (d/entity @conn :logseq.class/task))
:db/ident :logseq.class/Task}])
(defn- update-table-properties
[conn _search-db]
(let [old-new-props {:logseq.property/table-sorting :logseq.property.table/sorting
:logseq.property/table-filters :logseq.property.table/filters
:logseq.property/table-ordered-columns :logseq.property.table/ordered-columns
:logseq.property/table-hidden-columns :logseq.property.table/hidden-columns}
props-tx (mapv (fn [[old new]]
{:db/id (:db/id (d/entity @conn old))
:db/ident new})
old-new-props)]
;; Property changes need to be in their own tx for subsequent uses of properties to take effect
(ldb/transact! conn props-tx {:db-migrate? true})
(mapcat (fn [[old new]]
(->> (d/q '[:find ?b ?prop-v :in $ ?prop :where [?b ?prop ?prop-v]] @conn old)
(mapcat (fn [[id prop-value]]
[[:db/retract id old]
[:db/add id new prop-value]]))))
old-new-props)))
(def schema-version->updates
[[3 {:properties [:logseq.property/table-sorting :logseq.property/table-filters
:logseq.property/table-hidden-columns :logseq.property/table-ordered-columns]
@@ -60,7 +80,8 @@
[6 {:properties [:logseq.property.asset/remote-metadata]}]
[7 {:fix replace-original-name-content-with-title}]
[8 {:fix replace-object-and-page-type-with-node}]
[9 {:fix update-task-ident}]])
[9 {:fix update-task-ident}]
[10 {:fix update-table-properties}]])
(let [max-schema-version (apply max (map first schema-version->updates))]
(assert (<= db-schema/version max-schema-version))

View File

@@ -306,12 +306,13 @@
(defn- rollback
[repo block-ops-map-coll]
(let [ops (map (fn [m]
(keep (fn [[k op]]
(when (not= :block/uuid k)
op))
m))
block-ops-map-coll)]
(let [ops (mapcat
(fn [m]
(keep (fn [[k op]]
(when (not= :block/uuid k)
op))
m))
block-ops-map-coll)]
(client-op/add-ops repo ops)
nil))

View File

@@ -85,7 +85,7 @@
(if (> t1 t2)
(merge-update-ops update-op2 update-op1)
(let [{av-coll1 :av-coll block-uuid :block-uuid} (last update-op1)
{av-coll2 :av-coll} (last update-op1)]
{av-coll2 :av-coll} (last update-op2)]
[:update t2
{:block-uuid block-uuid
:av-coll (concat av-coll1 av-coll2)}]))))