From 5f200fbeef926b37063eca306e85bfdc21470946 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Sat, 19 Sep 2026 11:24:40 +0200 Subject: [PATCH] [chore:] Schema version 4 --- DataStore/SchemaMigration.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/DataStore/SchemaMigration.cs b/DataStore/SchemaMigration.cs index fe58ccf..ebbf1cd 100644 --- a/DataStore/SchemaMigration.cs +++ b/DataStore/SchemaMigration.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Linq; +using Newtonsoft.Json; namespace Logof_Client; @@ -12,7 +13,7 @@ namespace Logof_Client; public static class SchemaMigration { // Current schema version - increment when you make breaking changes - public const int CURRENT_SCHEMA_VERSION = 3; + public const int CURRENT_SCHEMA_VERSION = 4; // Dictionary of migration functions, keyed by the version they migrate TO private static readonly Dictionary> Migrations = new() @@ -22,7 +23,7 @@ public static class SchemaMigration // { 2, MigrateV1ToV2 }, // Example: Migration from v2 to v3 - // { 3, MigrateV2ToV3 }, + { 4, MigrateV3ToV4 }, }; /// @@ -93,12 +94,13 @@ public static class SchemaMigration /// Example migration function: from v2 to v3. /// Add a new required field with a default value. /// - private static JObject MigrateV2ToV3(JObject obj) + private static JObject MigrateV3ToV4(JObject obj) { // Example: Add a new field that didn't exist before - if (!obj.ContainsKey("new_required_field")) + if (!obj.ContainsKey("moduleConfig")) { - obj["new_required_field"] = "default_value"; + string deflt = JsonConvert.SerializeObject(new ModuleConfig()); + obj["moduleConfig"] = default; } return obj;