From a5993642186e084b856d20c86e056cee9114a7dc Mon Sep 17 00:00:00 2001 From: Himself65 Date: Tue, 11 Apr 2023 14:30:36 -0500 Subject: [PATCH] fix(y-indexeddb): migration for once (#1868) --- packages/y-indexeddb/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/y-indexeddb/src/index.ts b/packages/y-indexeddb/src/index.ts index 23f6698a18..8f37b4ce5f 100644 --- a/packages/y-indexeddb/src/index.ts +++ b/packages/y-indexeddb/src/index.ts @@ -238,7 +238,7 @@ export const createIndexedDBProvider = ( doc.on('destroy', handleDestroy); // only run promise below, otherwise the logic is incorrect const db = await dbPromise; - if (!allDb) { + if (!allDb || localStorage.getItem(`${dbName}-migration`) !== 'true') { allDb = await indexedDB.databases(); // run the migration await Promise.all( @@ -283,6 +283,7 @@ export const createIndexedDBProvider = ( } }) ); + localStorage.setItem(`${dbName}-migration`, 'true'); } const store = db .transaction('workspace', 'readwrite')