Add config migrations (#693)

Co-authored-by: Danielv123 <danielv@danielv.no>
This commit is contained in:
Cooldude2606andDanielv123 authored and GitHub committed 2024-11-26 23:14:56 +00:00
1 parent 05ca4eb25e
commit 4248e57dcb
7 files changed
+43 -9

No files matched your search

+11 -1
View File
@@ -187,6 +187,16 @@ export class Config<
declare static fieldDefinitions: ConfigDefs<any>;
declare ["constructor"]: typeof Config;
/**
* Handle migration between clusterio versions
*
* @param config - Input config read and validated from file
* @returns Output config to be loaded into the class
* @protected
*/
static migrations(config: Static<typeof this.jsonSchema>) {
return config;
}
fields: Fields;
_unknownFields: Record<string, FieldValue> = {};
@@ -223,7 +233,7 @@ export class Config<
) as Fields;
if (fields) {
this.update(fields, false, location);
this.update(this.constructor.migrations(fields), false, location);
}
}