mirror of
https://github.com/movie-web/movie-web.git
synced 2025-01-01 11:56:00 +00:00
migration error handling
This commit is contained in:
parent
f46263385b
commit
df5f1a5fdb
|
@ -44,9 +44,16 @@ export async function initializeStores() {
|
||||||
|
|
||||||
// Migrate over each version
|
// Migrate over each version
|
||||||
let mostRecentData = data;
|
let mostRecentData = data;
|
||||||
for (const version of relevantVersions) {
|
try {
|
||||||
if (version.migrate)
|
for (const version of relevantVersions) {
|
||||||
mostRecentData = await version.migrate(mostRecentData);
|
if (version.migrate)
|
||||||
|
mostRecentData = await version.migrate(mostRecentData);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`FAILED TO MIGRATE STORE ${internal.key}`, err);
|
||||||
|
// reset store to lastest version create
|
||||||
|
mostRecentData =
|
||||||
|
relevantVersions[relevantVersions.length - 1].create?.() ?? {};
|
||||||
}
|
}
|
||||||
|
|
||||||
store.save(mostRecentData);
|
store.save(mostRecentData);
|
||||||
|
|
Loading…
Reference in a new issue