From 0fb96ebb616a6ce29a9b9e5fc6e1993d56d8a057 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:38:05 -0500 Subject: [PATCH] Add --reset-schedule flag to reset collection schedule on re-install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CLI: --reset-schedule flag prepends TRUNCATE to 04_create_schedule_table.sql GUI: "Reset collection schedule to recommended defaults" checkbox Both pass resetSchedule to installer logic which truncates config.collection_schedule before the WHERE NOT EXISTS inserts re-populate with current defaults. Tested on sql2022 with update install — schedule reset to 33 collectors with current recommended frequencies. Closes #92 Co-Authored-By: Claude Opus 4.6 --- Installer/Program.cs | 13 +++++++++++++ InstallerGui/MainWindow.xaml | 6 ++++++ InstallerGui/MainWindow.xaml.cs | 2 ++ InstallerGui/Services/InstallationService.cs | 12 ++++++++++++ 4 files changed, 33 insertions(+) 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, "");