Finish removing the Range bucket type that was accidentally still able to be created
This commit is contained in:
parent
3fc8b654c7
commit
8f993adb47
6 changed files with 34 additions and 52 deletions
|
|
@ -6,7 +6,6 @@ const { StringField, NumberField } = foundry.data.fields;
|
|||
export const BucketTypes = {
|
||||
STRING: `string`,
|
||||
NUMBER: `number`,
|
||||
RANGE: `range`,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Default Subtables:
|
|||
tables that are parents to other tables.
|
||||
*/
|
||||
|
||||
const { deleteProperty, diffObject, expandObject, mergeObject } = foundry.utils;
|
||||
const { deleteProperty, diffObject, expandObject, isNewerVersion, mergeObject } = foundry.utils;
|
||||
|
||||
/**
|
||||
* The generic Database implementation, any subclasses should implement all of
|
||||
|
|
@ -275,7 +275,11 @@ export class Database {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
static requiresMigrationFrom(lastVersion) {
|
||||
return foundry.utils.isNewerVersion(__VERSION__, lastVersion);
|
||||
Logger.table({
|
||||
lastVersion,
|
||||
newer: isNewerVersion(__VERSION__, lastVersion),
|
||||
});
|
||||
return isNewerVersion(__VERSION__, lastVersion);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -289,7 +293,28 @@ export class Database {
|
|||
* @param {Notification} notif The progress bar notification used for
|
||||
* user feedback while performing migrations.
|
||||
*/
|
||||
static async migrateData(lastVersion, notif) {};
|
||||
static async migrateData(lastVersion, notif) {
|
||||
const totalSteps = 1;
|
||||
Logger.debug(lastVersion);
|
||||
|
||||
/*
|
||||
This migration is for going up to 1.0.3, getting rid of any tables that have
|
||||
a bucket type of range, since those were not supported within the initial
|
||||
release, but could still accidentally be created by users.
|
||||
*/
|
||||
if (isNewerVersion(`1.0.3`, lastVersion)) {
|
||||
Logger.log(`Migrating up to the v1.0.3 data structure`);
|
||||
const tables = game.settings.get(__ID__, `tables`);
|
||||
for (const table of Object.values(tables)) {
|
||||
if (table.buckets.type !== `range`) { continue };
|
||||
table.buckets.type = BucketTypes.NUMBER;
|
||||
table.buckets.showEmptyBuckets = true;
|
||||
};
|
||||
await game.settings.set(__ID__, `tables`, tables);
|
||||
notif.update({ pct: notif.pct + (1 / totalSteps) });
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue