diff --git a/packages/data-center/src/provider/affine/idb-kv.ts b/packages/data-center/src/provider/affine/idb-kv.ts index 37dcbe64df..07a12272d8 100644 --- a/packages/data-center/src/provider/affine/idb-kv.ts +++ b/packages/data-center/src/provider/affine/idb-kv.ts @@ -1,8 +1,10 @@ import { createStore, keys, setMany, getMany, clear } from 'idb-keyval'; +import * as idb from 'lib0/indexeddb.js'; type IDBInstance = { keys: () => Promise; clear: () => Promise; + deleteDB: () => Promise; setMany: (entries: [string, T][]) => Promise; getMany: (keys: string[]) => Promise; }; @@ -16,6 +18,7 @@ export function getDatabase( return { keys: () => keys(db), clear: () => clear(db), + deleteDB: () => idb.deleteDB(name), setMany: entries => setMany(entries, db), getMany: keys => getMany(keys, db), }; diff --git a/packages/data-center/src/provider/affine/utils.ts b/packages/data-center/src/provider/affine/utils.ts index 79da384dd5..f9cd139b0b 100644 --- a/packages/data-center/src/provider/affine/utils.ts +++ b/packages/data-center/src/provider/affine/utils.ts @@ -82,6 +82,7 @@ export const migrateBlobDB = async ( return [id, { id, blob }] as [string, PendingTask]; }); await newPendingDB.setMany(pendingEntries); - oldDB.clear(); - oldPendingDB.clear(); + + await oldDB.clear(); + await oldPendingDB.clear(); };