From f558b08c75e612b633b92699d7405c50145ee5bf Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 21 Apr 2026 16:53:04 -0600 Subject: [PATCH] Add a migration for the world setting to make it use an array of item schemas --- module/migrations/v3.0.0.mjs | 15 +++++++++++++-- module/settings/world.mjs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/module/migrations/v3.0.0.mjs b/module/migrations/v3.0.0.mjs index 3d230ae..acedfc8 100644 --- a/module/migrations/v3.0.0.mjs +++ b/module/migrations/v3.0.0.mjs @@ -26,6 +26,7 @@ export async function migrateTo3_0_0() { }, ); + // Migrating world actors worldOperations.push( ...await migrateCollection( game.actors, @@ -36,6 +37,7 @@ export async function migrateTo3_0_0() { ); warning.update({ pct: 0.25 }); + // Migrating all of the relevant compendiums for (const pack of packsToMigrate) { await pack.getDocuments(); @@ -57,11 +59,20 @@ export async function migrateTo3_0_0() { compendiumOperations = []; }; - warning.update({ pct: 0.8 }); - await foundry.documents.modifyBatch(worldOperations); + // Migrating the world setting + const defaultAttrs = game.settings.get(__ID__, `actorDefaultAttributes`)?.at(0); + if (defaultAttrs) { + const itemSchemas = []; + for (const [key, attr] of Object.entries(defaultAttrs)) { + itemSchemas.push(convertToItem(key, attr)); + }; + await game.settings.set(__ID__, `actorDefaultAttributes`, itemSchemas); + }; + warning.update({ pct: 0.9 }); + await foundry.documents.modifyBatch(worldOperations); finishMigrationWarning(warning, `3.0.0`); }; diff --git a/module/settings/world.mjs b/module/settings/world.mjs index a8dd616..f811d13 100644 --- a/module/settings/world.mjs +++ b/module/settings/world.mjs @@ -71,7 +71,7 @@ export function registerWorldSettings() { game.settings.register(__ID__, `actorDefaultAttributes`, { config: false, - type: Object, + type: Array, scope: `world`, });