fix(y-indexeddb): migration for once (#1868)

This commit is contained in:
Himself65 2023-04-11 14:30:36 -05:00 committed by GitHub
parent c0669359ed
commit a599364218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')