ds4/src/migration/002.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

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 {
getSceneMigrator,
migrateCollection,
2021-07-08 02:32:25 +02:00
migrateCompendiums,
getCompendiumMigrator,
getActorMigrator,
} from "./migrationHelpers.js";
2021-07-08 02:32:25 +02:00
/** @type {import("./migration.js").Migration["migrate"]} */
async function migrate() {
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);
}
/** @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
}
const migrateActor = getActorMigrator(migrateItem);
const migrateScene = getSceneMigrator(migrateActor);
2021-07-08 02:32:25 +02:00
const migrateCompendium = getCompendiumMigrator(
{ migrateItem, migrateActor, migrateScene },
2021-07-08 02:32:25 +02:00
{ migrateToTemplateEarly: false },
);
/** @type {import("./migration.js").Migration} */
export const migration = {
migrate,
migrateCompendium,
};