diff --git a/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs b/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs index 35caa1216..5f686eac3 100644 --- a/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs @@ -14,6 +14,8 @@ namespace NzbDrone.Core.Test.Configuration public void SetUp() { Mocker.SetConstant(Mocker.Resolve()); + + Db.All().ForEach(Db.Delete); } [Test] diff --git a/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs b/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs index f801eda79..c773e6224 100644 --- a/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs +++ b/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs @@ -16,11 +16,30 @@ namespace NzbDrone.Core.Datastore.Migration { protected override void MainDbUpgrade() { + Execute.WithConnection(EnableCompletedDownloadHandlingForNewUsers); + Execute.WithConnection(ConvertFolderSettings); Execute.WithConnection(AssociateImportedHistoryItems); } + private void EnableCompletedDownloadHandlingForNewUsers(IDbConnection conn, IDbTransaction tran) + { + using (IDbCommand cmd = conn.CreateCommand()) + { + cmd.Transaction = tran; + cmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'downloadedepisodesfolder'"; + + var result = cmd.ExecuteScalar(); + + if (result == null) + { + cmd.CommandText = @"INSERT INTO Config (Key, Value) VALUES ('enablecompleteddownloadhandling', 'True')"; + cmd.ExecuteNonQuery(); + } + } + } + private void ConvertFolderSettings(IDbConnection conn, IDbTransaction tran) { using (IDbCommand downloadClientsCmd = conn.CreateCommand())