diff --git a/RetainerTrack/Database/Migrations/20240524201345_ImportLegacyData.cs b/RetainerTrack/Database/Migrations/20240524201345_ImportLegacyData.cs index 332eaac..a559c61 100644 --- a/RetainerTrack/Database/Migrations/20240524201345_ImportLegacyData.cs +++ b/RetainerTrack/Database/Migrations/20240524201345_ImportLegacyData.cs @@ -4,97 +4,23 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using Dalamud.Plugin; -using LiteDB; using Microsoft.EntityFrameworkCore.Migrations; -using RetainerTrack.LegacyDb; #nullable disable -#pragma warning disable 0612 namespace RetainerTrack.Database.Migrations { /// public partial class ImportLegacyData : Migration { - public static DalamudPluginInterface PluginInterface { get; set; } - - private static readonly string[] PlayerColumns = new[] { "LocalContentId", "Name" }; - private static readonly string[] RetainerColumns = new []{ "LocalContentId", "Name", "WorldId", "OwnerLocalContentId" }; - /// protected override void Up(MigrationBuilder migrationBuilder) { - if (PluginInterface == null) - return; - - string legacyDatabaseFileName = Path.Join(PluginInterface.GetPluginConfigDirectory(), "retainer-data.litedb"); - if (!File.Exists(legacyDatabaseFileName)) - return; - - using var liteDatabase = new LiteDatabase(new ConnectionString - { - Filename = Path.Join(PluginInterface.GetPluginConfigDirectory(), "retainer-data.litedb"), - Connection = ConnectionType.Direct, - Upgrade = true, - }, - new BsonMapper - { - ResolveCollectionName = (type) => - { - if (type == typeof(LegacyPlayer)) - return LegacyPlayer.CollectionName; - - if (type == typeof(LegacyRetainer)) - return LegacyRetainer.CollectionName; - throw new ArgumentOutOfRangeException(nameof(type)); - } - }); - liteDatabase.GetCollection() - .EnsureIndex(x => x.Id); - liteDatabase.GetCollection() - .EnsureIndex(x => x.Id); - - List allPlayers = liteDatabase.GetCollection().FindAll().ToList(); - object[,] playersToInsert = To2DArray( - allPlayers.Select(player => new object[] { player.Id, player.Name }).ToList(), - PlayerColumns.Length); - - migrationBuilder.InsertData( - table:"Players", - columns: PlayerColumns, - values: playersToInsert); - - List allRetainers = liteDatabase.GetCollection().FindAll().ToList(); - object[,] retainersToInsert = To2DArray( - allRetainers.Select(retainer => new object[] { retainer.Id, retainer.Name, retainer.WorldId, retainer.OwnerContentId }).ToList(), - RetainerColumns.Length); - - migrationBuilder.InsertData( - table: "Retainers", - columns: RetainerColumns, values: retainersToInsert); - } - - [SuppressMessage("Performance", "CA1814")] - private static object[,] To2DArray(IReadOnlyList data, int columnCount) - { - object[,] result = new object[data.Count, columnCount]; - for (int i = 0; i < data.Count; i++) - { - for (int j = 0; j < columnCount; j++) - { - result[i, j] = data[i][j]; - } - } - return result; } /// protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.Sql("DELETE FROM Players"); - migrationBuilder.Sql("DELETE FROM Retainers"); } } } - -#pragma warning restore 0612 diff --git a/RetainerTrack/LegacyDb/LegacyPlayer.cs b/RetainerTrack/LegacyDb/LegacyPlayer.cs deleted file mode 100644 index 2a9679a..0000000 --- a/RetainerTrack/LegacyDb/LegacyPlayer.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace RetainerTrack.LegacyDb; - -[Obsolete] -internal sealed class LegacyPlayer -{ - public static string CollectionName => "Player"; - - public ulong Id { get; set; } - public string? Name { get; set; } -} diff --git a/RetainerTrack/LegacyDb/LegacyRetainer.cs b/RetainerTrack/LegacyDb/LegacyRetainer.cs deleted file mode 100644 index 9c1afb6..0000000 --- a/RetainerTrack/LegacyDb/LegacyRetainer.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace RetainerTrack.LegacyDb; - -[Obsolete] -internal sealed class LegacyRetainer -{ - public static string CollectionName => "Retainer"; - - public ulong Id { get; set; } - public string? Name { get; set; } - public ushort WorldId { get; set; } - public ulong OwnerContentId { get; set; } -} diff --git a/RetainerTrack/RetainerTrack.csproj b/RetainerTrack/RetainerTrack.csproj index 61a604f..ed2d724 100644 --- a/RetainerTrack/RetainerTrack.csproj +++ b/RetainerTrack/RetainerTrack.csproj @@ -2,10 +2,11 @@ net8.0-windows - 3.2 + 4.0 12.0 enable win-x64 + none true false false @@ -27,13 +28,11 @@ - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/RetainerTrack/RetainerTrackPlugin.cs b/RetainerTrack/RetainerTrackPlugin.cs index 0bc5ffe..76d6e9e 100644 --- a/RetainerTrack/RetainerTrackPlugin.cs +++ b/RetainerTrack/RetainerTrackPlugin.cs @@ -77,8 +77,6 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin private static void RunMigrations(IServiceProvider serviceProvider) { - ImportLegacyData.PluginInterface = serviceProvider.GetRequiredService(); - using var scope = serviceProvider.CreateScope(); using var dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.Database.Migrate(); diff --git a/RetainerTrack/packages.lock.json b/RetainerTrack/packages.lock.json index 0dfcfdb..28b2620 100644 --- a/RetainerTrack/packages.lock.json +++ b/RetainerTrack/packages.lock.json @@ -17,12 +17,6 @@ "resolved": "2.1.12", "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" }, - "LiteDB": { - "type": "Direct", - "requested": "[5.0.17, )", - "resolved": "5.0.17", - "contentHash": "cKPvkdlzIts3ZKu/BzoIc/Y71e4VFKlij4LyioPFATZMot+wB7EAm1FFbZSJez6coJmQUoIg/3yHE1MMU+zOdg==" - }, "Microsoft.EntityFrameworkCore.Sqlite": { "type": "Direct", "requested": "[8.0.5, )", @@ -33,83 +27,6 @@ "SQLitePCLRaw.bundle_e_sqlite3": "2.1.6" } }, - "Microsoft.EntityFrameworkCore.Tools": { - "type": "Direct", - "requested": "[8.0.5, )", - "resolved": "8.0.5", - "contentHash": "ZG5X2uznVmw+Mk0HVv3YHiTaGcCANDmZg81/9GLvE5zU4B11oxuM1+tndkYCFoM9CSN0/+XfB89TVYViKXYiRA==", - "dependencies": { - "Microsoft.EntityFrameworkCore.Design": "8.0.5" - } - }, - "Microsoft.Extensions.DependencyInjection": { - "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" - } - }, - "Humanizer.Core": { - "type": "Transitive", - "resolved": "2.14.1", - "contentHash": "lQKvtaTDOXnoVJ20ibTuSIOf2i0uO0MPbDhd1jm238I+U/2ZnRENj0cktKZhtchBMtCUSRQ5v4xBCUbKNmyVMw==" - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==" - }, - "Microsoft.CodeAnalysis.Analyzers": { - "type": "Transitive", - "resolved": "3.3.3", - "contentHash": "j/rOZtLMVJjrfLRlAMckJLPW/1rze9MT1yfWqSIbUPGRu1m1P0fuo9PmqapwsmePfGB5PJrudQLvmUOAMF0DqQ==" - }, - "Microsoft.CodeAnalysis.Common": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "lwAbIZNdnY0SUNoDmZHkVUwLO8UyNnyyh1t/4XsbFxi4Ounb3xszIYZaWhyj5ZjyfcwqwmtMbE7fUTVCqQEIdQ==", - "dependencies": { - "Microsoft.CodeAnalysis.Analyzers": "3.3.3", - "System.Collections.Immutable": "6.0.0", - "System.Reflection.Metadata": "6.0.1", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Text.Encoding.CodePages": "6.0.0" - } - }, - "Microsoft.CodeAnalysis.CSharp": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "cM59oMKAOxvdv76bdmaKPy5hfj+oR+zxikWoueEB7CwTko7mt9sVKZI8Qxlov0C/LuKEG+WQwifepqL3vuTiBQ==", - "dependencies": { - "Microsoft.CodeAnalysis.Common": "[4.5.0]" - } - }, - "Microsoft.CodeAnalysis.CSharp.Workspaces": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "h74wTpmGOp4yS4hj+EvNzEiPgg/KVs2wmSfTZ81upJZOtPkJsVkgfsgtxxqmAeapjT/vLKfmYV0bS8n5MNVP+g==", - "dependencies": { - "Humanizer.Core": "2.14.1", - "Microsoft.CodeAnalysis.CSharp": "[4.5.0]", - "Microsoft.CodeAnalysis.Common": "[4.5.0]", - "Microsoft.CodeAnalysis.Workspaces.Common": "[4.5.0]" - } - }, - "Microsoft.CodeAnalysis.Workspaces.Common": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "l4dDRmGELXG72XZaonnOeORyD/T5RpEu5LGHOUIhnv+MmUWDY/m1kWXGwtcgQ5CJ5ynkFiRnIYzTKXYjUs7rbw==", - "dependencies": { - "Humanizer.Core": "2.14.1", - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "Microsoft.CodeAnalysis.Common": "[4.5.0]", - "System.Composition": "6.0.0", - "System.IO.Pipelines": "6.0.3", - "System.Threading.Channels": "6.0.0" - } - }, "Microsoft.Data.Sqlite.Core": { "type": "Transitive", "resolved": "8.0.5", @@ -139,18 +56,6 @@ "resolved": "8.0.5", "contentHash": "LzoKedC+9A8inF5d3iIzgyv/JDXgKrtpYoGIC3EqGWuHVDm9s/IHHApeTOTbzvnr7yBVV+nmYfyT1nwtzRDp0Q==" }, - "Microsoft.EntityFrameworkCore.Design": { - "type": "Transitive", - "resolved": "8.0.5", - "contentHash": "HWYnbuMwllSCsZjfKj3Vz+HDGOCyGlTMYjI7tZH5pK7AuiGNHOdshCnWlEFEuDV6oAadWfXGTDmkmV53gwTqSQ==", - "dependencies": { - "Humanizer.Core": "2.14.1", - "Microsoft.CodeAnalysis.CSharp.Workspaces": "4.5.0", - "Microsoft.EntityFrameworkCore.Relational": "8.0.5", - "Microsoft.Extensions.DependencyModel": "8.0.0", - "Mono.TextTemplating": "2.2.1" - } - }, "Microsoft.EntityFrameworkCore.Relational": { "type": "Transitive", "resolved": "8.0.5", @@ -198,6 +103,14 @@ "Microsoft.Extensions.Primitives": "8.0.0" } }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + } + }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -244,14 +157,6 @@ "resolved": "8.0.0", "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" }, - "Mono.TextTemplating": { - "type": "Transitive", - "resolved": "2.2.1", - "contentHash": "KZYeKBET/2Z0gY1WlTAK7+RHTl7GSbtvTLDXEZZojUdAPqpQNDL6tHv7VUpqfX5VEOh+uRGKaZXkuD253nEOBQ==", - "dependencies": { - "System.CodeDom": "4.4.0" - } - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.6", @@ -282,98 +187,11 @@ "SQLitePCLRaw.core": "2.1.6" } }, - "System.CodeDom": { - "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "2sCCb7doXEwtYAbqzbF/8UAeDRMNmPaQbU2q50Psg1J9KzumyVVCgKQY8s53WIPTufNT0DpSe9QRvVjOzfDWBA==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Composition": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "d7wMuKQtfsxUa7S13tITC8n1cQzewuhD5iDjZtK2prwFfKVzdYtgrTHgjaV03Zq7feGQ5gkP85tJJntXwInsJA==", - "dependencies": { - "System.Composition.AttributedModel": "6.0.0", - "System.Composition.Convention": "6.0.0", - "System.Composition.Hosting": "6.0.0", - "System.Composition.Runtime": "6.0.0", - "System.Composition.TypedParts": "6.0.0" - } - }, - "System.Composition.AttributedModel": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "WK1nSDLByK/4VoC7fkNiFuTVEiperuCN/Hyn+VN30R+W2ijO1d0Z2Qm0ScEl9xkSn1G2MyapJi8xpf4R8WRa/w==" - }, - "System.Composition.Convention": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "XYi4lPRdu5bM4JVJ3/UIHAiG6V6lWWUlkhB9ab4IOq0FrRsp0F4wTyV4Dj+Ds+efoXJ3qbLqlvaUozDO7OLeXA==", - "dependencies": { - "System.Composition.AttributedModel": "6.0.0" - } - }, - "System.Composition.Hosting": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "w/wXjj7kvxuHPLdzZ0PAUt++qJl03t7lENmb2Oev0n3zbxyNULbWBlnd5J5WUMMv15kg5o+/TCZFb6lSwfaUUQ==", - "dependencies": { - "System.Composition.Runtime": "6.0.0" - } - }, - "System.Composition.Runtime": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "qkRH/YBaMPTnzxrS5RDk1juvqed4A6HOD/CwRcDGyPpYps1J27waBddiiq1y93jk2ZZ9wuA/kynM+NO0kb3PKg==" - }, - "System.Composition.TypedParts": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "iUR1eHrL8Cwd82neQCJ00MpwNIBs4NZgXzrPqx8NJf/k4+mwBO0XCRmHYJT4OLSwDDqh5nBLJWkz5cROnrGhRA==", - "dependencies": { - "System.Composition.AttributedModel": "6.0.0", - "System.Composition.Hosting": "6.0.0", - "System.Composition.Runtime": "6.0.0" - } - }, - "System.IO.Pipelines": { - "type": "Transitive", - "resolved": "6.0.3", - "contentHash": "ryTgF+iFkpGZY1vRQhfCzX0xTdlV3pyaTTqRu2ETbEv+HlV7O6y7hyQURnghNIXvctl5DuZ//Dpks6HdL/Txgw==" - }, "System.Memory": { "type": "Transitive", "resolved": "4.5.3", "contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA==" }, - "System.Reflection.Metadata": { - "type": "Transitive", - "resolved": "6.0.1", - "contentHash": "III/lNMSn0ZRBuM9m5Cgbiho5j81u0FAEagFX5ta2DKbljZ3T0IpD8j+BIiHQPeKqJppWS9bGEp6JnKnWKze0g==", - "dependencies": { - "System.Collections.Immutable": "6.0.0" - } - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Text.Encoding.CodePages": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, "System.Text.Encodings.Web": { "type": "Transitive", "resolved": "8.0.0", @@ -386,11 +204,6 @@ "dependencies": { "System.Text.Encodings.Web": "8.0.0" } - }, - "System.Threading.Channels": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "TY8/9+tI0mNaUMgntOxxaq2ndTkdXqLSxvPmas7XEqOlv9lQtB7wLjYGd756lOaO7Dvb5r/WXhluM+0Xe87v5Q==" } }, "net8.0-windows7.0/win-x64": { @@ -399,14 +212,6 @@ "resolved": "2.1.6", "contentHash": "2ObJJLkIUIxRpOUlZNGuD4rICpBnrBR5anjyfUFQep4hMOIeqW+XGQYzrNmHSVz5xSWZ3klSbh7sFR6UyDj68Q==" }, - "System.Text.Encoding.CodePages": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, "System.Text.Encodings.Web": { "type": "Transitive", "resolved": "8.0.0",