Phase 6 (Stufe 4b): Config-Migration aus mongoexport-JSON

- ConfigMigrator.RunFromJson: importiert Accounts, Copytrading-Settings
  (Limit-Felder aus dem Alt-Account-Dokument) und Master-Trader aus
  PolyTraderDB.accounts.json / .trackers.json nach MySQL. Idempotent.
- Robuste JSON-Helfer (mongoexport: Dezimale als Strings, null moeglich).
- CLI: PolyTrader.App --migrate-json [ordner=MongoDB].
- .gitignore: MongoDB/ (Exporte enthalten Secrets) ausgeschlossen.
- Ergebnis: 3 Accounts, 3 Settings, 32 Master-Trader in MySQL.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-07-05 14:54:07 +02:00
co-authored by Claude Opus 4.8
parent e21a3515d1
commit 9dbecc9514
3 changed files with 211 additions and 0 deletions
+30
View File
@@ -33,6 +33,14 @@ internal static class Program
return;
}
// Config-Migration aus mongoexport-JSON (Ordner, Default "MongoDB") -> MySQL.
if (args.Length > 0 && string.Equals(args[0], "--migrate-json", StringComparison.OrdinalIgnoreCase))
{
var folder = args.Length > 1 ? args[1] : "MongoDB";
RunConfigMigrationFromJson(folder);
return;
}
ApplicationConfiguration.Initialize();
var modules = new System.Collections.Generic.List<IPolyTraderModule>
@@ -238,4 +246,26 @@ internal static class Program
Services.ConfigMigrator.Run(mongoConn, mongoDbName, mySql);
}
private static void RunConfigMigrationFromJson(string folder)
{
var config = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
.SetBasePath(System.IO.Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true)
.AddJsonFile("appsettings.Local.json", optional: true)
.AddEnvironmentVariables()
.Build();
var mySql = config["Database:MySqlConnectionString"] ?? string.Empty;
if (string.IsNullOrWhiteSpace(mySql))
{
Console.WriteLine("FEHLER: Database:MySqlConnectionString fehlt (appsettings.Local.json).");
return;
}
if (!System.IO.Path.IsPathRooted(folder))
folder = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), folder);
Services.ConfigMigrator.RunFromJson(folder, mySql);
}
}