diff --git a/deps/db/src/logseq/db/frontend/malli_schema.cljs b/deps/db/src/logseq/db/frontend/malli_schema.cljs index 808d1cf13e..4149f7ab51 100644 --- a/deps/db/src/logseq/db/frontend/malli_schema.cljs +++ b/deps/db/src/logseq/db/frontend/malli_schema.cljs @@ -282,12 +282,15 @@ (def schema-version [:map - [:schema/version :int]]) + [:db/ident :keyword] + [:schema/version :int] + [:block/tx-id {:optional true} :int]]) (def db-ident [:map [:db/ident :keyword] - [:db/type {:optional true} :string]]) + [:db/type {:optional true} :string] + [:block/tx-id {:optional true} :int]]) (def macro [:map diff --git a/deps/db/src/logseq/db/sqlite/create_graph.cljs b/deps/db/src/logseq/db/sqlite/create_graph.cljs index 2c77771913..0f3c1b98f7 100644 --- a/deps/db/src/logseq/db/sqlite/create_graph.cljs +++ b/deps/db/src/logseq/db/sqlite/create_graph.cljs @@ -1,13 +1,16 @@ (ns logseq.db.sqlite.create-graph "Helper fns for creating a DB graph" (:require [logseq.db.sqlite.util :as sqlite-util] + [logseq.db.frontend.schema :as db-schema] [logseq.db.frontend.property :as db-property] [logseq.db.frontend.property.util :as db-property-util] [datascript.core :as d])) (defn build-db-initial-data [config-content] - (let [initial-files [{:block/uuid (d/squuid) + (let [initial-data [{:db/ident :db/type :db/type "db"} + {:db/ident :schema/version :schema/version db-schema/version}] + initial-files [{:block/uuid (d/squuid) :file/path (str "logseq/" "config.edn") :file/content config-content :file/last-modified-at (js/Date.)} @@ -33,4 +36,4 @@ :block/name (sqlite-util/sanitize-page-name k-name) :block/uuid (d/squuid)})]))) db-property/built-in-properties)] - (concat initial-files default-properties))) \ No newline at end of file + (concat initial-data initial-files default-properties))) \ No newline at end of file diff --git a/scripts/src/logseq/tasks/db_graph/create_graph.cljs b/scripts/src/logseq/tasks/db_graph/create_graph.cljs index f70606f7c2..5db641bd7d 100644 --- a/scripts/src/logseq/tasks/db_graph/create_graph.cljs +++ b/scripts/src/logseq/tasks/db_graph/create_graph.cljs @@ -24,8 +24,6 @@ (defn- setup-init-data "Setup initial data same as frontend.handler.repo/create-db" [conn] - ;; App doesn't persist :db/type but it does load it each time - (d/transact! conn [{:db/id -1 :db/ident :db/type :db/type "db"}]) (let [config-content (or (some-> (find-on-classpath "templates/config.edn") fs/readFileSync str) (do (println "Setting graph's config to empty since no templates/config.edn was found.") "{}"))] diff --git a/src/main/frontend/handler/repo.cljs b/src/main/frontend/handler/repo.cljs index 3b12a140cf..fe2c390871 100644 --- a/src/main/frontend/handler/repo.cljs +++ b/src/main/frontend/handler/repo.cljs @@ -537,8 +537,6 @@ _ (start-repo-db-if-not-exists! full-graph-name) _ (state/add-repo! {:url full-graph-name}) _ (route-handler/redirect-to-home!) - _ (db/transact! full-graph-name [(react/kv :db/type "db") - (react/kv :schema/version db-schema/version {:id -2})]) initial-data (sqlite-create-graph/build-db-initial-data config/config-default-content) _ (db/transact! full-graph-name initial-data) _ (repo-config-handler/set-repo-config-state! full-graph-name config/config-default-content)