39 lines
2.5 KiB
TypeScript
39 lines
2.5 KiB
TypeScript
export const STORAGE_DATABASE_NAME = "blender-web-metadata";
|
|
export const STORAGE_SCHEMA_VERSION = 7;
|
|
|
|
export const STORAGE_STORES = ["smoke", "project", "asset", "snapshot", "operation_log", "operation_quarantine", "setting", "lod_manifest", "simulation_manifest", "simulation_quarantine", "migration"] as const;
|
|
|
|
export function upgradeStorageSchema(db: IDBDatabase, transaction: IDBTransaction, oldVersion: number): void {
|
|
if (oldVersion < 1 && !db.objectStoreNames.contains("smoke")) {
|
|
db.createObjectStore("smoke", { keyPath: "id" });
|
|
}
|
|
if (oldVersion < 2) {
|
|
if (!db.objectStoreNames.contains("project")) db.createObjectStore("project", { keyPath: "id" });
|
|
if (!db.objectStoreNames.contains("asset")) db.createObjectStore("asset", { keyPath: "id" });
|
|
if (!db.objectStoreNames.contains("snapshot")) db.createObjectStore("snapshot", { keyPath: "id" });
|
|
if (!db.objectStoreNames.contains("operation_log")) db.createObjectStore("operation_log", { keyPath: "id" });
|
|
if (!db.objectStoreNames.contains("setting")) db.createObjectStore("setting", { keyPath: "id" });
|
|
if (!db.objectStoreNames.contains("migration")) db.createObjectStore("migration", { keyPath: "id" });
|
|
transaction.objectStore("migration").put({ id: "schema-2", version: 2, appliedAt: new Date().toISOString() });
|
|
}
|
|
if (oldVersion < 3) {
|
|
if (!db.objectStoreNames.contains("lod_manifest")) db.createObjectStore("lod_manifest", { keyPath: "id" });
|
|
transaction.objectStore("migration").put({ id: "schema-3", version: 3, appliedAt: new Date().toISOString() });
|
|
}
|
|
if (oldVersion < 4) {
|
|
transaction.objectStore("migration").put({ id: "schema-4", version: 4, appliedAt: new Date().toISOString() });
|
|
}
|
|
if (oldVersion < 5) {
|
|
if (!db.objectStoreNames.contains("operation_quarantine")) db.createObjectStore("operation_quarantine", { keyPath: "id" });
|
|
transaction.objectStore("migration").put({ id: "schema-5", version: 5, appliedAt: new Date().toISOString() });
|
|
}
|
|
if (oldVersion < 6) {
|
|
if (!db.objectStoreNames.contains("simulation_manifest")) db.createObjectStore("simulation_manifest", { keyPath: "id" });
|
|
transaction.objectStore("migration").put({ id: "schema-6", version: 6, appliedAt: new Date().toISOString() });
|
|
}
|
|
if (oldVersion < 7) {
|
|
if (!db.objectStoreNames.contains("simulation_quarantine")) db.createObjectStore("simulation_quarantine", { keyPath: "id" });
|
|
transaction.objectStore("migration").put({ id: "schema-7", version: 7, appliedAt: new Date().toISOString() });
|
|
}
|
|
}
|