2022-11-09 03:02:27 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
import {
|
2023-07-09 20:53:18 +02:00
|
|
|
getSceneMigrator,
|
|
|
|
migrateCollection,
|
2022-11-09 03:02:27 +01:00
|
|
|
migrateCompendiums,
|
2023-07-09 20:53:18 +02:00
|
|
|
getCompendiumMigrator,
|
|
|
|
getActorMigrator,
|
|
|
|
} from "./migrationHelpers.js";
|
2022-11-09 03:02:27 +01:00
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import("./migration.js").Migration["migrate"]} */
|
2022-11-17 00:12:29 +01:00
|
|
|
async function migrate() {
|
2023-07-09 22:19:44 +02:00
|
|
|
const itemsResult = await migrateCollection(game.items, migrateItem);
|
|
|
|
const actorsResult = await migrateCollection(game.actors, migrateActor);
|
|
|
|
const scenesResult = await migrateCollection(game.scenes, migrateScene);
|
|
|
|
const compendiumsResult = await migrateCompendiums(migrateCompendium);
|
|
|
|
return itemsResult === "error" ||
|
|
|
|
actorsResult === "error" ||
|
|
|
|
scenesResult === "error" ||
|
|
|
|
compendiumsResult === "error"
|
|
|
|
? "error"
|
|
|
|
: "success";
|
2022-11-09 03:02:27 +01:00
|
|
|
}
|
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import('./migrationHelpers.js').Migrator<Item>} */
|
|
|
|
async function migrateItem(item) {
|
|
|
|
if (item.type === "spell") {
|
|
|
|
await item.update({ system: { allowsDefense: false } });
|
|
|
|
}
|
2022-11-09 03:02:27 +01:00
|
|
|
}
|
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
const migrateActor = getActorMigrator(migrateItem);
|
|
|
|
const migrateScene = getSceneMigrator(migrateActor);
|
|
|
|
const migrateCompendium = getCompendiumMigrator({ migrateItem, migrateActor, migrateScene });
|
2022-11-09 03:02:27 +01:00
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import("./migration.js").Migration} */
|
2022-11-09 03:02:27 +01:00
|
|
|
export const migration = {
|
|
|
|
migrate,
|
|
|
|
migrateCompendium,
|
|
|
|
};
|