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();