From 20df31919db4f72ceb6b17b8beebf7a895ca1b25 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 26 Jun 2023 20:49:15 +0300 Subject: [PATCH] Check for event type to prevent multiple runs on the same row --- .../Datastore/Migration/034_history_fix_data_titles.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Datastore/Migration/034_history_fix_data_titles.cs b/src/NzbDrone.Core/Datastore/Migration/034_history_fix_data_titles.cs index b6dddad1e..70428deda 100644 --- a/src/NzbDrone.Core/Datastore/Migration/034_history_fix_data_titles.cs +++ b/src/NzbDrone.Core/Datastore/Migration/034_history_fix_data_titles.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Datastore.Migration using (var selectCommand = conn.CreateCommand()) { selectCommand.Transaction = tran; - selectCommand.CommandText = "SELECT \"Id\", \"Data\" FROM \"History\""; + selectCommand.CommandText = "SELECT \"Id\", \"Data\", \"EventType\" FROM \"History\""; using var reader = selectCommand.ExecuteReader(); @@ -31,18 +31,19 @@ namespace NzbDrone.Core.Datastore.Migration { var id = reader.GetInt32(0); var data = reader.GetString(1); + var eventType = reader.GetInt32(2); if (!string.IsNullOrWhiteSpace(data)) { var jsonObject = Json.Deserialize(data); - if (jsonObject.ContainsKey("title")) + if (eventType == 1 && jsonObject.ContainsKey("title")) { jsonObject.Add("grabTitle", jsonObject.Value("title")); jsonObject.Remove("title"); } - if (jsonObject.ContainsKey("bookTitle")) + if (eventType != 1 && jsonObject.ContainsKey("bookTitle")) { jsonObject.Add("title", jsonObject.Value("bookTitle")); jsonObject.Remove("bookTitle");