diff --git a/Installer/Program.cs b/Installer/Program.cs index db6bceac..6689f45b 100644 --- a/Installer/Program.cs +++ b/Installer/Program.cs @@ -84,6 +84,7 @@ static async Task Main(string[] args) */ bool automatedMode = args.Length > 0; bool reinstallMode = args.Any(a => a.Equals("--reinstall", StringComparison.OrdinalIgnoreCase)); + bool resetSchedule = args.Any(a => a.Equals("--reset-schedule", StringComparison.OrdinalIgnoreCase)); bool trustCert = args.Any(a => a.Equals("--trust-cert", StringComparison.OrdinalIgnoreCase)); /*Parse encryption option (default: Mandatory)*/ @@ -103,6 +104,7 @@ static async Task Main(string[] args) /*Filter out option flags to get positional arguments*/ var filteredArgs = args .Where(a => !a.Equals("--reinstall", StringComparison.OrdinalIgnoreCase)) + .Where(a => !a.Equals("--reset-schedule", StringComparison.OrdinalIgnoreCase)) .Where(a => !a.Equals("--trust-cert", StringComparison.OrdinalIgnoreCase)) .Where(a => !a.StartsWith("--encrypt=", StringComparison.OrdinalIgnoreCase)) .ToArray(); @@ -167,6 +169,7 @@ Automated mode with command-line arguments Console.WriteLine(); Console.WriteLine("Options:"); Console.WriteLine(" --reinstall Drop existing database and perform clean install"); + Console.WriteLine(" --reset-schedule Reset collection schedule to recommended defaults"); Console.WriteLine(" --encrypt= Connection encryption: optional (default), mandatory, strict"); Console.WriteLine(" --trust-cert Trust server certificate without validation (default: require valid cert)"); return ExitCodes.InvalidArguments; @@ -610,6 +613,16 @@ Connection pooling handles the underlying socket reuse { string sqlContent = await File.ReadAllTextAsync(sqlFile); + /* + Reset schedule to defaults if requested — truncate before the + INSERT...WHERE NOT EXISTS re-populates with current recommended values + */ + if (resetSchedule && fileName.StartsWith("04_", StringComparison.Ordinal)) + { + sqlContent = "TRUNCATE TABLE config.collection_schedule;\nGO\n" + sqlContent; + Console.Write("(resetting schedule) "); + } + /* Remove SQLCMD directives (:r includes) as we're executing files directly */ diff --git a/InstallerGui/MainWindow.xaml b/InstallerGui/MainWindow.xaml index 93bc3122..5f032534 100644 --- a/InstallerGui/MainWindow.xaml +++ b/InstallerGui/MainWindow.xaml @@ -180,6 +180,12 @@ Margin="0,0,0,10" Foreground="{DynamicResource ForegroundBrush}"/> + + + { diff --git a/InstallerGui/Services/InstallationService.cs b/InstallerGui/Services/InstallationService.cs index ebb5b585..7c061461 100644 --- a/InstallerGui/Services/InstallationService.cs +++ b/InstallerGui/Services/InstallationService.cs @@ -324,6 +324,7 @@ public static async Task ExecuteInstallationAsync( string connectionString, List sqlFiles, bool cleanInstall, + bool resetSchedule = false, IProgress? progress = null, Func? preValidationAction = null, CancellationToken cancellationToken = default) @@ -410,6 +411,17 @@ Execute SQL files { string sqlContent = await File.ReadAllTextAsync(sqlFile, cancellationToken).ConfigureAwait(false); + /*Reset schedule to defaults if requested*/ + if (resetSchedule && fileName.StartsWith("04_", StringComparison.Ordinal)) + { + sqlContent = "TRUNCATE TABLE config.collection_schedule;\nGO\n" + sqlContent; + progress?.Report(new InstallationProgress + { + Message = "Resetting schedule to recommended defaults...", + Status = "Info" + }); + } + /*Remove SQLCMD directives*/ sqlContent = SqlCmdDirectivePattern.Replace(sqlContent, "");