2021-06-26 22:02:00 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-07-08 02:32:25 +02:00
|
|
|
import {
|
2023-07-09 20:53:18 +02:00
|
|
|
getSceneMigrator,
|
|
|
|
migrateCollection,
|
2021-07-08 02:32:25 +02:00
|
|
|
migrateCompendiums,
|
2023-07-09 20:53:18 +02:00
|
|
|
getCompendiumMigrator,
|
|
|
|
getActorMigrator,
|
|
|
|
} from "./migrationHelpers.js";
|
2021-07-08 02:32:25 +02: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 20:53:18 +02:00
|
|
|
await migrateCollection(game.items, migrateItem);
|
|
|
|
await migrateCollection(game.actors, migrateActor);
|
|
|
|
await migrateCollection(game.scenes, migrateScene);
|
2021-07-08 02:32:25 +02:00
|
|
|
await migrateCompendiums(migrateCompendium);
|
|
|
|
}
|
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import('./migrationHelpers.js').Migrator<Item>} */
|
|
|
|
async function migrateItem(item) {
|
|
|
|
if (item.type === "equipment" || item.type === "trinket") {
|
|
|
|
await item.update({ type: item.type === "equipment" ? "loot" : "equipment" });
|
|
|
|
}
|
2021-07-08 02:32:25 +02:00
|
|
|
}
|
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
const migrateActor = getActorMigrator(migrateItem);
|
|
|
|
const migrateScene = getSceneMigrator(migrateActor);
|
2021-07-08 02:32:25 +02:00
|
|
|
const migrateCompendium = getCompendiumMigrator(
|
2023-07-09 20:53:18 +02:00
|
|
|
{ migrateItem, migrateActor, migrateScene },
|
2021-07-08 02:32:25 +02:00
|
|
|
{ migrateToTemplateEarly: false },
|
|
|
|
);
|
2022-02-14 00:58:23 +01:00
|
|
|
|
2023-07-09 20:53:18 +02:00
|
|
|
/** @type {import("./migration.js").Migration} */
|
2022-02-14 00:58:23 +01:00
|
|
|
export const migration = {
|
|
|
|
migrate,
|
|
|
|
migrateCompendium,
|
|
|
|
};
|