Add a migration for the world setting to make it use an array of item schemas

This commit is contained in:
Oliver 2026-04-21 16:53:04 -06:00
parent 6461057647
commit f558b08c75
2 changed files with 14 additions and 3 deletions

View file

@ -26,6 +26,7 @@ export async function migrateTo3_0_0() {
}, },
); );
// Migrating world actors
worldOperations.push( worldOperations.push(
...await migrateCollection( ...await migrateCollection(
game.actors, game.actors,
@ -36,6 +37,7 @@ export async function migrateTo3_0_0() {
); );
warning.update({ pct: 0.25 }); warning.update({ pct: 0.25 });
// Migrating all of the relevant compendiums
for (const pack of packsToMigrate) { for (const pack of packsToMigrate) {
await pack.getDocuments(); await pack.getDocuments();
@ -57,11 +59,20 @@ export async function migrateTo3_0_0() {
compendiumOperations = []; compendiumOperations = [];
}; };
warning.update({ pct: 0.8 }); 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`); finishMigrationWarning(warning, `3.0.0`);
}; };

View file

@ -71,7 +71,7 @@ export function registerWorldSettings() {
game.settings.register(__ID__, `actorDefaultAttributes`, { game.settings.register(__ID__, `actorDefaultAttributes`, {
config: false, config: false,
type: Object, type: Array,
scope: `world`, scope: `world`,
}); });