enhance: import-debug-transit support db type

This commit is contained in:
rcmerci
2025-09-09 17:14:28 +08:00
parent c139e6be93
commit 78660f9374
4 changed files with 13 additions and 9 deletions

View File

@@ -40,7 +40,7 @@
(fn write-transit-str* [o]
(try (transit/write writer o)
(catch :default e
(prn ::write-transit-str o)
(prn ::write-transit-str (type o) o)
(js/console.trace)
(throw e))))))

View File

@@ -18,11 +18,13 @@
;; Get the runtime id from http://localhost:9630/runtimes, pick the one which shows `browser-worker`
(defn worker-repl
[]
(let [runtime-id (->> (api/repl-runtimes :db-worker)
(map :client-id)
first)]
(api/repl :db-worker {:runtime-id runtime-id})))
([]
(let [runtime-id (->> (api/repl-runtimes :db-worker)
(map :client-id)
first)]
(api/repl :db-worker {:runtime-id runtime-id})))
([runtime-id]
(api/repl :db-worker {:runtime-id runtime-id})))
(defn runtime-id-list
[app]

View File

@@ -2,6 +2,7 @@
"Handles DB graph imports"
(:require [cljs.pprint :as pprint]
[clojure.edn :as edn]
[datascript.core :as d]
[frontend.config :as config]
[frontend.db :as db]
[frontend.handler.notification :as notification]
@@ -38,7 +39,8 @@
(defn import-from-debug-transit!
[bare-graph-name raw finished-ok-handler]
(let [graph (str config/db-version-prefix bare-graph-name)
datoms (ldb/read-transit-str raw)]
db-or-datoms (ldb/read-transit-str raw)
datoms (if (d/db? db-or-datoms) (vec (d/datoms db-or-datoms :eavt)) db-or-datoms)]
(p/do!
(persist-db/<new graph {:import-type :debug-transit
:datoms datoms})

View File

@@ -20,11 +20,11 @@
upgrade-result-coll)))
(deftest ^:focus migration-results=>client-ops
(testing "65.2 => 65.10"
(testing "65.2 => 65.11"
(let [db-transit (str (fs-node/readFileSync "src/test/migration/65.2.transit"))
db (ldb/read-transit-str db-transit)
conn (d/conn-from-db db)
migration-result (db-migrate/migrate conn {:target-version "65.10"})
migration-result (db-migrate/migrate conn {:target-version "65.11"})
client-ops (rtc-migrate/migration-results=>client-ops migration-result)]
(prn :migration-result "================================================================")
(pp/pprint (merge (select-keys migration-result [:from-version :to-version])