From beafd5621743fb683a1a189036e43a81d57a9a45 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 8 Oct 2024 22:52:37 -0400 Subject: [PATCH] Add migration --- .../DdonDatabaseBuilder.cs | 2 +- .../00000022_EquipPresetMigration.cs | 25 +++++++++++++++++++ Arrowgene.Ddon.Shared/Model/Storages.cs | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Arrowgene.Ddon.Database/Sql/Core/Migration/00000022_EquipPresetMigration.cs diff --git a/Arrowgene.Ddon.Database/DdonDatabaseBuilder.cs b/Arrowgene.Ddon.Database/DdonDatabaseBuilder.cs index 1104bb88a..323770ee6 100644 --- a/Arrowgene.Ddon.Database/DdonDatabaseBuilder.cs +++ b/Arrowgene.Ddon.Database/DdonDatabaseBuilder.cs @@ -14,7 +14,7 @@ public static class DdonDatabaseBuilder private static readonly ILogger Logger = LogProvider.Logger(typeof(DdonDatabaseBuilder)); private const string DefaultSchemaFile = "Script/schema_sqlite.sql"; - public const uint Version = 21; + public const uint Version = 22; public static IDatabase Build(DatabaseSetting settings) { diff --git a/Arrowgene.Ddon.Database/Sql/Core/Migration/00000022_EquipPresetMigration.cs b/Arrowgene.Ddon.Database/Sql/Core/Migration/00000022_EquipPresetMigration.cs new file mode 100644 index 000000000..310ba0f8a --- /dev/null +++ b/Arrowgene.Ddon.Database/Sql/Core/Migration/00000022_EquipPresetMigration.cs @@ -0,0 +1,25 @@ +using System.Data.Common; + +namespace Arrowgene.Ddon.Database.Sql.Core.Migration +{ + public class EquipPresetMigration : IMigrationStrategy + { + public uint From => 21; + public uint To => 22; + + private readonly DatabaseSetting DatabaseSetting; + + public EquipPresetMigration(DatabaseSetting databaseSetting) + { + DatabaseSetting = databaseSetting; + } + + public bool Migrate(IDatabase db, DbConnection conn) + { + string adaptedSchema = DdonDatabaseBuilder.GetAdaptedSchema(DatabaseSetting, "Script/migration_equipment_preset.sql"); + db.Execute(conn, adaptedSchema); + return true; + } + } +} + diff --git a/Arrowgene.Ddon.Shared/Model/Storages.cs b/Arrowgene.Ddon.Shared/Model/Storages.cs index b0a363f5c..4cf8e5869 100644 --- a/Arrowgene.Ddon.Shared/Model/Storages.cs +++ b/Arrowgene.Ddon.Shared/Model/Storages.cs @@ -317,7 +317,7 @@ public List AsCDataEquipItemInfo(EquipType equipType) public List AsCDataCharacterEquipInfo(EquipType equipType) { return GetItems(equipType) - .Select((x, index) => new {item = x, slot = (byte)(index+1)}) + .Select((x, index) => new {item = x, slot = (byte)(index + 1)}) .Where(tuple => tuple.item != null) .Select(tuple => new CDataCharacterEquipInfo() {