mirror of
https://github.com/logseq/logseq.git
synced 2026-05-24 04:34:14 +00:00
fix: transact bootstrap properties first
This commit is contained in:
26
deps/db/src/logseq/db/frontend/property.cljs
vendored
26
deps/db/src/logseq/db/frontend/property.cljs
vendored
@@ -68,6 +68,17 @@
|
||||
:property/ui-position {:title "Property position"
|
||||
:schema {:type :keyword
|
||||
:hide? true}}
|
||||
:property/schema.classes
|
||||
{:title "Property classes"
|
||||
:schema {:type :entity
|
||||
:cardinality :many
|
||||
:public? false
|
||||
:hide? true}}
|
||||
:property.value/content
|
||||
{:title "Property value"
|
||||
:schema {:type :any
|
||||
:public? false
|
||||
:hide? true}}
|
||||
:block/alias {:title "Alias"
|
||||
:attribute :block/alias
|
||||
:schema {:type :page
|
||||
@@ -144,19 +155,6 @@
|
||||
:schema {:type :datetime
|
||||
:public? false
|
||||
:hide? true}}
|
||||
:logseq.property.attribute/property-schema-classes
|
||||
{:title "Property classes"
|
||||
:attribute :property/schema.classes
|
||||
:schema {:type :entity
|
||||
:cardinality :many
|
||||
:public? false
|
||||
:hide? true}}
|
||||
:logseq.property.attribute/property-value-content
|
||||
{:title "Property value"
|
||||
:attribute :property.value/content
|
||||
:schema {:type :any
|
||||
:public? false
|
||||
:hide? true}}
|
||||
|
||||
:logseq.property.node/display-type {:title "Node Display Type"
|
||||
:schema {:type :keyword
|
||||
@@ -567,7 +565,7 @@
|
||||
:block/refs :block/path-refs :block/link
|
||||
:block/title :block/closed-value-property
|
||||
:block/created-at :block/updated-at
|
||||
:logseq.property.attribute/kv-value :logseq.property.attribute/property-schema-classes :logseq.property.attribute/property-value-content})
|
||||
:logseq.property.attribute/kv-value})
|
||||
|
||||
(assert (= db-attribute-properties
|
||||
(set (keep (fn [[k {:keys [attribute]}]] (when attribute k))
|
||||
|
||||
5
deps/db/src/logseq/db/frontend/schema.cljs
vendored
5
deps/db/src/logseq/db/frontend/schema.cljs
vendored
@@ -115,10 +115,7 @@
|
||||
{:block/name {:db/index true} ; remove db/unique for :block/name
|
||||
;; closed value
|
||||
:block/closed-value-property {:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/many}
|
||||
:property/schema.classes {:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/many}
|
||||
:property.value/content {}}))
|
||||
:db/cardinality :db.cardinality/many}}))
|
||||
|
||||
(def retract-attributes
|
||||
#{:block/refs
|
||||
|
||||
17
deps/db/src/logseq/db/sqlite/create_graph.cljs
vendored
17
deps/db/src/logseq/db/sqlite/create_graph.cljs
vendored
@@ -55,6 +55,17 @@
|
||||
(mark-block-as-built-in {:block/uuid (:block/uuid block)}))
|
||||
properties (build-initial-properties* db-property/built-in-properties)
|
||||
;; Tx order matters. built-in-property must come first as all properties depend on it.
|
||||
bootstrap-property-ids (map #(select-keys % [:db/ident :block/uuid :db/cardinality :db/valueType])
|
||||
(keep
|
||||
(fn [property]
|
||||
(when (and (:db/ident property) (= "property" (namespace (:db/ident property))))
|
||||
property))
|
||||
properties))
|
||||
properties (map (fn [block]
|
||||
(if (and (:db/ident block) (= "property" (namespace (:db/ident block))))
|
||||
(dissoc block :db/ident :db/cardinality :db/valueType)
|
||||
block))
|
||||
properties)
|
||||
tx (concat [built-in-property]
|
||||
properties
|
||||
;; Adding built-ins must come after initial properties
|
||||
@@ -68,6 +79,7 @@
|
||||
(assert (string/starts-with? (str block-uuid) "00000002") m)))
|
||||
|
||||
{:tx tx
|
||||
:bootstrap-property-ids bootstrap-property-ids
|
||||
:properties (filter entity-util/property? properties)}))
|
||||
|
||||
(def built-in-pages-names
|
||||
@@ -170,7 +182,7 @@
|
||||
:file/content ""
|
||||
:file/created-at (js/Date.)
|
||||
:file/last-modified-at (js/Date.)}]
|
||||
{properties-tx :tx :keys [properties]} (build-initial-properties)
|
||||
{properties-tx :tx :keys [bootstrap-property-ids properties]} (build-initial-properties)
|
||||
db-ident->properties (zipmap (map :db/ident properties) properties)
|
||||
default-classes (build-initial-classes db-ident->properties)
|
||||
default-pages (->> (map sqlite-util/build-new-page built-in-pages-names)
|
||||
@@ -184,7 +196,8 @@
|
||||
classes-tx (concat (map #(dissoc % :db/ident) bootstrap-classes)
|
||||
(remove bootstrap-class? default-classes))
|
||||
;; Order of tx is critical. bootstrap-class-ids bootstraps properties-tx and classes-tx
|
||||
tx (vec (concat bootstrap-class-ids initial-data properties-tx classes-tx
|
||||
tx (vec (concat bootstrap-property-ids bootstrap-class-ids
|
||||
initial-data properties-tx classes-tx
|
||||
initial-files default-pages hidden-pages))]
|
||||
(validate-tx-for-duplicate-idents tx)
|
||||
tx))
|
||||
|
||||
4
deps/db/src/logseq/db/sqlite/util.cljs
vendored
4
deps/db/src/logseq/db/sqlite/util.cljs
vendored
@@ -73,7 +73,7 @@
|
||||
(if (qualified-keyword? k)
|
||||
(assoc r k v)
|
||||
(if (= k :cardinality)
|
||||
:db/cardinality
|
||||
(assoc r :db/cardinality v)
|
||||
(assoc r (keyword "property" k) v))))
|
||||
{}
|
||||
prop-schema))
|
||||
@@ -104,7 +104,7 @@
|
||||
:block/uuid (or block-uuid (common-uuid/gen-uuid :db-ident-block-uuid db-ident'))
|
||||
:block/title (name prop-name)
|
||||
:db/index true
|
||||
:db/cardinality (if (= :many (:cardinality prop-schema))
|
||||
:db/cardinality (if (= :many (:db/cardinality prop-schema))
|
||||
:db.cardinality/many
|
||||
:db.cardinality/one)
|
||||
:block/order (db-order/gen-key)}
|
||||
|
||||
Reference in New Issue
Block a user