From 8852b501f59d5603420f0ef10aa4d0124b0608fa Mon Sep 17 00:00:00 2001 From: cesnimda Date: Thu, 9 Apr 2026 21:35:17 +0200 Subject: [PATCH] Create missing MySQL rule settings tables --- JobTrackerApi/Program.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/JobTrackerApi/Program.cs b/JobTrackerApi/Program.cs index 2c99d61..9b591ed 100644 --- a/JobTrackerApi/Program.cs +++ b/JobTrackerApi/Program.cs @@ -949,6 +949,46 @@ LIMIT 1;"; EnsureMySqlColumn(conn, "AspNetUsers", "GoogleEmail", "ALTER TABLE `AspNetUsers` ADD COLUMN `GoogleEmail` longtext NULL;"); EnsureMySqlColumn(conn, "AspNetUsers", "GoogleLinkedAt", "ALTER TABLE `AspNetUsers` ADD COLUMN `GoogleLinkedAt` datetime NULL;"); + if (!HasMySqlTable(conn, "RuleSettings")) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"CREATE TABLE IF NOT EXISTS `RuleSettings` ( +`Id` int NOT NULL, +`AppliedFollowUpDays` int NOT NULL, +`AppliedGhostDays` int NOT NULL, +`OfferFollowUpDays` int NOT NULL, +`OfferGhostDays` int NOT NULL, +`FeedbackFollowUpDays` int NOT NULL, +`FeedbackGhostDays` int NOT NULL, +PRIMARY KEY (`Id`) +);"; + cmd.ExecuteNonQuery(); + } + + using (var seedRuleSettings = conn.CreateCommand()) + { + seedRuleSettings.CommandText = @"INSERT INTO `RuleSettings` (`Id`, `AppliedFollowUpDays`, `AppliedGhostDays`, `OfferFollowUpDays`, `OfferGhostDays`, `FeedbackFollowUpDays`, `FeedbackGhostDays`) +SELECT 1, 14, 30, 7, 14, 7, 14 +WHERE NOT EXISTS (SELECT 1 FROM `RuleSettings` WHERE `Id` = 1);"; + seedRuleSettings.ExecuteNonQuery(); + } + + if (!HasMySqlTable(conn, "UserRuleSettings")) + { + using var cmd = conn.CreateCommand(); + cmd.CommandText = @"CREATE TABLE IF NOT EXISTS `UserRuleSettings` ( +`OwnerUserId` varchar(255) NOT NULL, +`AppliedFollowUpDays` int NOT NULL, +`AppliedGhostDays` int NOT NULL, +`OfferFollowUpDays` int NOT NULL, +`OfferGhostDays` int NOT NULL, +`FeedbackFollowUpDays` int NOT NULL, +`FeedbackGhostDays` int NOT NULL, +PRIMARY KEY (`OwnerUserId`) +);"; + cmd.ExecuteNonQuery(); + } + if (!HasMySqlTable(conn, "SystemEmailSettings")) { using var cmd = conn.CreateCommand();