Fix data migration error when page is opened for the first time
See https://autonomous.zone/@d1/117076455141813238
This commit is contained in:
parent
5eb0b2d736
commit
fe742076e5
2 changed files with 3 additions and 3 deletions
|
|
@ -633,7 +633,7 @@
|
|||
|
||||
(def data-migrations
|
||||
{4 (fn =0004-convert-internal-ids [db]
|
||||
(let [cursor (db/open-cursor db ::db/posts ::db/post-internal-id ::db/all)
|
||||
(let [cursor (db/open-cursor db ::db/posts ::db/all {:index ::db/post-internal-id})
|
||||
result (db/transduce-cursor (filter (comp string? (j/get :internal_id))) cursor)]
|
||||
(.then result
|
||||
(fn [rows]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
(doto request
|
||||
(.addEventListener "success"
|
||||
(fn [ev]
|
||||
(let [db (.-result request)]
|
||||
(let [db (-> ev .-target .-result)]
|
||||
; see https://javascript.info/indexeddb#parallel-update-problem
|
||||
(.addEventListener db "versionchange"
|
||||
(fn []
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
key-range (if (= key-range ::all)
|
||||
(js/IDBKeyRange.lowerBound js/Number.NEGATIVE_INFINITY)
|
||||
key-range)
|
||||
direction ({:asc "next" :desc "prev"} direction direction)]
|
||||
direction ({:asc "next" :desc "prev"} direction "next")]
|
||||
(if index
|
||||
(.openCursor (.index store (str index)) key-range direction)
|
||||
(.openCursor store key-range direction)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue