Skip to content

Commit 965ff30

Browse files
committed
fix: invalid data for old graphs
skip db validate when migrating db
1 parent 4462634 commit 965ff30

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main/frontend/worker/db/migrate.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@
551551
tx-data' (concat
552552
[(sqlite-util/kv :logseq.kv/schema-version version)]
553553
tx-data)
554-
r (ldb/transact! conn tx-data' {:db-migrate? true})
554+
r (ldb/transact! conn tx-data' {:db-migrate? true
555+
:skip-validate-db? true})
555556
migrate-updates (cond-> migrate-updates
556557
rename-db-idents (assoc :rename-db-idents rename-db-idents-coll))]
557558
(println "DB schema migrated to" version)

src/main/frontend/worker/db/validate.cljs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[frontend.worker.db.migrate :as db-migrate]
77
[frontend.worker.shared-service :as shared-service]
88
[logseq.db :as ldb]
9+
[logseq.db.frontend.class :as db-class]
910
[logseq.db.frontend.validate :as db-validate]))
1011

1112
(defn- get-property-by-title
@@ -21,6 +22,15 @@
2122
(fn [{:keys [entity dispatch-key]}]
2223
(let [entity (d/entity db (:db/id entity))]
2324
(cond
25+
;; missing :db/ident
26+
(and (ldb/class? entity) (nil? (:db/ident entity)) (:block/title entity))
27+
[[:db/add (:db/id entity) :db/ident (db-class/create-user-class-ident-from-name db (:block/title entity))]]
28+
(and
29+
(= (:block/title (:logseq.property/created-from-property entity)) "description")
30+
(nil? (:block/page entity)))
31+
(let [property-id (:db/id (:logseq.property/created-from-property entity))]
32+
[[:db/add (:db/id entity) :block/page property-id]
33+
[:db/add (:db/id entity) :block/parent property-id]])
2434
(and (:db/ident entity)
2535
(:logseq.property/built-in? entity)
2636
(:block/parent entity))

0 commit comments

Comments
 (0)