From 2de4b67d1f39ebbf2188f80ad1721687c999b509 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 27 Jul 2012 23:59:11 -0700 Subject: [PATCH] Migration will clean unmapped history items --- .../Datastore/Migrations/Migration20120727.cs | 25 +++++++++++++++++++ NzbDrone.Core/NzbDrone.Core.csproj | 1 + 2 files changed, 26 insertions(+) create mode 100644 NzbDrone.Core/Datastore/Migrations/Migration20120727.cs diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20120727.cs b/NzbDrone.Core/Datastore/Migrations/Migration20120727.cs new file mode 100644 index 000000000..44ef7d46d --- /dev/null +++ b/NzbDrone.Core/Datastore/Migrations/Migration20120727.cs @@ -0,0 +1,25 @@ +using System; +using System.Data; +using Migrator.Framework; +using NzbDrone.Common; + +namespace NzbDrone.Core.Datastore.Migrations +{ + + [Migration(20120727)] + public class Migration20120727 : NzbDroneMigration + { + protected override void MainDbUpgrade() + { + Database.ExecuteNonQuery(@"DELETE FROM History + WHERE HistoryId IN + ( + SELECT History.HistoryId + FROM History + LEFT OUTER JOIN Episodes + ON History.EpisodeId = Episodes.EpisodeId + WHERE Episodes.Title is null + )"); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 3f7acc5fd..edf77d7e4 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -227,6 +227,7 @@ +