mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
Ensure local graphs have uuid
This commit is contained in:
2
deps/db/src/logseq/db/frontend/schema.cljs
vendored
2
deps/db/src/logseq/db/frontend/schema.cljs
vendored
@@ -37,7 +37,7 @@
|
||||
(map (juxt :major :minor)
|
||||
[(parse-schema-version x) (parse-schema-version y)])))
|
||||
|
||||
(def version (parse-schema-version "65.17"))
|
||||
(def version (parse-schema-version "65.18"))
|
||||
|
||||
(defn major-version
|
||||
"Return a number.
|
||||
|
||||
@@ -235,7 +235,9 @@
|
||||
import-type
|
||||
(into (sqlite-util/import-tx import-type))
|
||||
graph-git-sha
|
||||
(conj (sqlite-util/kv :logseq.kv/graph-git-sha graph-git-sha)))
|
||||
(conj (sqlite-util/kv :logseq.kv/graph-git-sha graph-git-sha))
|
||||
true
|
||||
(conj (sqlite-util/kv :logseq.kv/graph-uuid (common-uuid/gen-uuid))))
|
||||
initial-files (build-initial-files config-content)
|
||||
{properties-tx :tx :keys [properties]} (build-initial-properties)
|
||||
db-ident->properties (zipmap (map :db/ident properties) properties)
|
||||
|
||||
@@ -155,8 +155,10 @@
|
||||
(deftest build-db-initial-data-test
|
||||
(testing "idempotent initial-data"
|
||||
(letfn [(remove-ignored-attrs&entities [init-data]
|
||||
(let [[before after] (split-with #(not= :logseq.kv/graph-created-at (:db/ident %)) init-data)
|
||||
init-data* (concat before (rest after))]
|
||||
(let [ignored-idents #{:logseq.kv/graph-created-at :logseq.kv/graph-uuid}
|
||||
init-data* (remove (fn [ent]
|
||||
(contains? ignored-idents (:db/ident ent)))
|
||||
init-data)]
|
||||
(map (fn [ent] (dissoc ent
|
||||
:block/created-at :block/updated-at
|
||||
:file/last-modified-at :file/created-at
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
[frontend.worker.db.rename-db-ident :as rename-db-ident]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.uuid :as common-uuid]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.frontend.class :as db-class]
|
||||
[logseq.db.frontend.property :as db-property]
|
||||
@@ -163,6 +164,12 @@
|
||||
(when (:logseq.property/ui-position e)
|
||||
[:db/retract (:e d) :logseq.property/ui-position]))))))
|
||||
|
||||
(defn- ensure-graph-uuid
|
||||
[db]
|
||||
(let [graph-uuid (:kv/value (d/entity db :logseq.kv/graph-uuid))]
|
||||
(when-not graph-uuid
|
||||
[(sqlite-util/kv :logseq.kv/graph-uuid (common-uuid/gen-uuid))])))
|
||||
|
||||
(def schema-version->updates
|
||||
"A vec of tuples defining datascript migrations. Each tuple consists of the
|
||||
schema version integer and a migration map. A migration map can have keys of :properties, :classes
|
||||
@@ -180,7 +187,8 @@
|
||||
:logseq.property.asset/external-url}
|
||||
{})]
|
||||
["65.16" {:properties [:logseq.property.asset/external-file-name]}]
|
||||
["65.17" {:properties [:logseq.property.publish/published-url]}]])
|
||||
["65.17" {:properties [:logseq.property.publish/published-url]}]
|
||||
["65.18" {:fix ensure-graph-uuid}]])
|
||||
|
||||
(let [[major minor] (last (sort (map (comp (juxt :major :minor) db-schema/parse-schema-version first)
|
||||
schema-version->updates)))]
|
||||
|
||||
@@ -189,6 +189,8 @@
|
||||
:s3-key key
|
||||
:schema-version (str major-schema-version)
|
||||
:graph-name remote-graph-name
|
||||
;; FIXME: use local graph uuid instead of creating new one
|
||||
:graph-uuid (:kv/value (:logseq.kv/graph-uuid @conn))
|
||||
:encrypted-aes-key
|
||||
(ldb/write-transit-str encrypted-aes-key)}))]
|
||||
(if-let [graph-uuid (:graph-uuid upload-resp)]
|
||||
|
||||
Reference in New Issue
Block a user