Fix issue with draw shapes rename not working on some dbs

This commit is contained in:
Mitchell McCaffrey 2021-08-20 09:01:05 +10:00
parent 3331fa1431
commit c767f35590

View File

@ -19,6 +19,7 @@ import { getDefaultMaps } from "./maps";
import { getDefaultTokens } from "./tokens"; import { getDefaultTokens } from "./tokens";
import { Outline } from "./types/Outline"; import { Outline } from "./types/Outline";
import { Group, GroupContainer } from "./types/Group"; import { Group, GroupContainer } from "./types/Group";
import cloneDeep from "lodash.clonedeep";
export type UpgradeEventHandler = (versionNumber: number) => void; export type UpgradeEventHandler = (versionNumber: number) => void;
@ -878,9 +879,27 @@ export const versions: Record<number, VersionCallback> = {
}); });
}); });
}, },
// v1.10.0 (patch 1) - Rename drawShapes and fogShapes in state again (some people's didn't work)
40(v, onUpgrade) {
v.stores({}).upgrade((tx) => {
onUpgrade?.(40);
tx.table("states")
.toCollection()
.modify((state) => {
if (state.drawShapes) {
state.drawings = cloneDeep(state.drawShapes);
delete state.drawShapes;
}
if (state.fogShapes) {
state.fogs = cloneDeep(state.fogShapes);
delete state.fogShapes;
}
});
});
},
}; };
export const latestVersion = 39; export const latestVersion = 40;
/** /**
* Load versions onto a database up to a specific version number * Load versions onto a database up to a specific version number