diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs deleted file mode 100644 index 62ed62be3..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/070_delay_profileFixture.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class delay_profileFixture : MigrationTest - { - [Test] - public void should_migrate_old_delays() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 1, - Name = "OneHour", - Cutoff = 0, - Items = "[]" - }); - - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 2, - Name = "TwoHours", - Cutoff = "{}", - Items = "[]" - }); - }); - - var allProfiles = db.Query("SELECT * FROM DelayProfiles"); - - allProfiles.Should().HaveCount(3); - allProfiles.Should().OnlyContain(c => c.PreferredProtocol == 1); - allProfiles.Should().OnlyContain(c => c.TorrentDelay == 0); - allProfiles.Should().Contain(c => c.UsenetDelay == 60); - allProfiles.Should().Contain(c => c.UsenetDelay == 120); - } - - [Test] - public void should_create_tag_for_delay_profile() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 1, - Name = "OneHour", - Cutoff = 0, - Items = "[]" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - - tags.Should().HaveCount(1); - tags.First().Label.Should().Be("delay-60"); - } - - [Test] - public void should_add_tag_to_series_that_had_a_profile_with_delay_attached() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - GrabDelay = 1, - Name = "OneHour", - Cutoff = 0, - Items = "[]" - }); - - c.Insert.IntoTable("Series").Row(new - { - TvdbId = 0, - TvRageId = 0, - Title = "Series", - TitleSlug = "series", - CleanTitle = "series", - Status = 0, - Images = "[]", - Path = @"C:\Test\Series", - Monitored = 1, - SeasonFolder = 1, - RunTime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - Tags = "[1]" - }); - }); - - var tag = db.Query("SELECT Id, Label FROM Tags").Single(); - var series = db.Query("SELECT Tags FROM Series"); - - series.Should().HaveCount(1); - series.First().Tags.Should().BeEquivalentTo(tag.Id); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs deleted file mode 100644 index ad31df44c..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/071_unknown_quality_in_profileFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class unknown_quality_in_profileFixture : MigrationTest - { - [Test] - public void should_add_unknown_to_old_profile() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - Id = 0, - Name = "SDTV", - Cutoff = 1, - Items = "[ { \"quality\": 1, \"allowed\": true } ]", - Language = 1 - }); - }); - - var profiles = db.Query("SELECT Items FROM Profiles LIMIT 1"); - - var items = profiles.First().Items; - items.Should().HaveCount(2); - items.First().Quality.Should().Be(0); - items.First().Allowed.Should().Be(false); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs deleted file mode 100644 index 59f66b25a..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/072_history_downloadIdFixture.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class history_downloadIdFixture : MigrationTest - { - [Test] - public void should_move_grab_id_from_date_to_columns() - { - var db = WithMigrationTestDb(c => - { - InsertHistory(c, new Dictionary - { - { "indexer", "test" }, - { "downloadClientId", "123" } - }); - - InsertHistory(c, new Dictionary - { - { "indexer", "test" }, - { "downloadClientId", "abc" } - }); - }); - - var history = db.Query("SELECT DownloadId, Data FROM History"); - - history.Should().HaveCount(2); - history.Should().NotContain(c => c.Data.ContainsKey("downloadClientId")); - history.Should().Contain(c => c.DownloadId == "123"); - history.Should().Contain(c => c.DownloadId == "abc"); - } - - [Test] - public void should_leave_items_with_no_grabid() - { - var db = WithMigrationTestDb(c => - { - InsertHistory(c, new Dictionary - { - { "indexer", "test" }, - { "downloadClientId", "123" } - }); - - InsertHistory(c, new Dictionary - { - { "indexer", "test" } - }); - }); - - var history = db.Query("SELECT DownloadId, Data FROM History"); - - history.Should().HaveCount(2); - history.Should().NotContain(c => c.Data.ContainsKey("downloadClientId")); - history.Should().Contain(c => c.DownloadId == "123"); - history.Should().Contain(c => c.DownloadId == null); - } - - [Test] - public void should_leave_other_data() - { - var db = WithMigrationTestDb(c => - { - InsertHistory(c, new Dictionary - { - { "indexer", "test" }, - { "group", "test2" }, - { "downloadClientId", "123" } - }); - }); - - var history = db.Query("SELECT DownloadId, Data FROM History").Single(); - - history.Data.Should().NotContainKey("downloadClientId"); - history.Data.Should().Contain(new KeyValuePair("indexer", "test")); - history.Data.Should().Contain(new KeyValuePair("group", "test2")); - - history.DownloadId.Should().Be("123"); - } - - private void InsertHistory(NzbDroneMigrationBase migrationBase, Dictionary data) - { - migrationBase.Insert.IntoTable("History").Row(new - { - EpisodeId = 1, - SeriesId = 1, - SourceTitle = "Test", - Date = DateTime.Now, - Quality = "{}", - Data = data.ToJson(), - EventType = 1 - }); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs deleted file mode 100644 index 29d8d411d..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class force_lib_updateFixture : MigrationTest - { - [Test] - public void should_not_fail_on_empty_db() - { - var db = WithMigrationTestDb(); - - db.Query("SELECT * FROM ScheduledTasks").Should().BeEmpty(); - db.Query("SELECT * FROM Series").Should().BeEmpty(); - } - - [Test] - public void should_reset_job_last_execution_time() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("ScheduledTasks").Row(new - { - TypeName = "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand", - Interval = 10, - LastExecution = "2000-01-01 00:00:00" - }); - - c.Insert.IntoTable("ScheduledTasks").Row(new - { - TypeName = "NzbDrone.Core.Backup.BackupCommand", - Interval = 10, - LastExecution = "2000-01-01 00:00:00" - }); - }); - - var jobs = db.Query("SELECT TypeName, LastExecution FROM ScheduledTasks"); - - jobs.Single(c => c.TypeName == "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand") - .LastExecution.Year.Should() - .Be(2014); - - jobs.Single(c => c.TypeName == "NzbDrone.Core.Backup.BackupCommand") - .LastExecution.Year.Should() - .Be(2000); - } - - [Test] - public void should_reset_series_last_sync_time() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00" - }); - - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 2, - TvRageId = 2, - Title = "Title2", - CleanTitle = "CleanTitle2", - Status = 1, - Images = "", - Path = "c:\\test2", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00" - }); - }); - - var series = db.Query("SELECT LastInfoSync FROM Series"); - - series.Should().OnlyContain(c => c.LastInfoSync.Value.Year == 2014); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs deleted file mode 100644 index 296c8cf8b..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/079_dedupe_tagsFixture.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class dedupe_tagsFixture : MigrationTest - { - [Test] - public void should_not_fail_if_series_tags_are_null() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - tags.Should().HaveCount(1); - } - - [Test] - public void should_not_fail_if_series_tags_are_empty() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[]" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - tags.Should().HaveCount(1); - } - - [Test] - public void should_remove_duplicate_labels_from_tags() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var tags = db.Query("SELECT * FROM Tags"); - tags.Should().HaveCount(1); - } - - [Test] - public void should_not_allow_duplicate_tag_to_be_inserted() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - Assert.That(() => db.Query("INSERT INTO Tags (Label) VALUES ('test')"), Throws.Exception); - } - - [Test] - public void should_replace_duplicated_tag_with_proper_tag() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[2]" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var series = db.Query("SELECT Tags FROM Series WHERE Id = 1").Single(); - series.Tags.First().Should().Be(1); - } - - [Test] - public void should_only_update_affected_series() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 1, - TvRageId = 1, - Title = "Title1", - CleanTitle = "CleanTitle1", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[2]" - }); - - c.Insert.IntoTable("Series").Row(new - { - Tvdbid = 2, - TvRageId = 2, - Title = "Title2", - CleanTitle = "CleanTitle2", - Status = 1, - Images = "", - Path = "c:\\test", - Monitored = 1, - SeasonFolder = 1, - Runtime = 0, - SeriesType = 0, - UseSceneNumbering = 0, - LastInfoSync = "2000-01-01 00:00:00", - Tags = "[]" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - - c.Insert.IntoTable("Tags").Row(new - { - Label = "test" - }); - }); - - var series = db.Query("SELECT Tags FROM Series WHERE Id = 2").Single(); - series.Tags.Should().BeEmpty(); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs deleted file mode 100644 index afd2aab45..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/081_move_dot_prefix_to_transmission_categoryFixture.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class move_dot_prefix_to_transmission_categoryFixture : MigrationTest - { - [Test] - public void should_not_fail_if_no_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Sab", - Implementation = "Sabnzbd", - Settings = new - { - Host = "127.0.0.1", - TvCategory = "abc" - }.ToJson(), - ConfigContract = "SabnzbdSettings" - }); - }); - - var downloadClients = db.Query("SELECT Settings FROM DownloadClients"); - - downloadClients.Should().HaveCount(1); - downloadClients.First().Settings.ToObject().TvCategory.Should().Be("abc"); - } - - [Test] - public void should_be_updated_for_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new - { - Host = "127.0.0.1", - TvCategory = "abc" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var downloadClients = db.Query("SELECT Settings FROM DownloadClients"); - - downloadClients.Should().HaveCount(1); - downloadClients.First().Settings.ToObject().TvCategory.Should().Be(".abc"); - } - - [Test] - public void should_leave_empty_category_untouched() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new - { - Host = "127.0.0.1", - TvCategory = "" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var downloadClients = db.Query("SELECT Settings FROM DownloadClients"); - - downloadClients.Should().HaveCount(1); - downloadClients.First().Settings.ToObject().TvCategory.Should().Be(""); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs deleted file mode 100644 index 8b4b237e6..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/084_update_quality_minmax_sizeFixture.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class update_quality_minmax_sizeFixture : MigrationTest - { - [Test] - public void should_not_fail_if_empty() - { - var db = WithMigrationTestDb(); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().BeEmpty(); - } - - [Test] - public void should_set_rawhd_to_null() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("QualityDefinitions").Row(new - { - Quality = 1, - Title = "SDTV", - MinSize = 0, - MaxSize = 100 - }) - .Row(new - { - Quality = 10, - Title = "RawHD", - MinSize = 0, - MaxSize = 100 - }); - }); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().HaveCount(2); - qualityDefinitions.First(v => v.Quality == 10).MaxSize.Should().NotHaveValue(); - } - - [Test] - public void should_set_zero_maxsize_to_null() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("QualityDefinitions").Row(new - { - Quality = 1, - Title = "SDTV", - MinSize = 0, - MaxSize = 0 - }); - }); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().HaveCount(1); - qualityDefinitions.First(v => v.Quality == 1).MaxSize.Should().NotHaveValue(); - } - - [Test] - public void should_preserve_values() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("QualityDefinitions").Row(new - { - Quality = 1, - Title = "SDTV", - MinSize = 0, - MaxSize = 100 - }) - .Row(new - { - Quality = 10, - Title = "RawHD", - MinSize = 0, - MaxSize = 100 - }); - }); - - var qualityDefinitions = db.Query("SELECT * FROM QualityDefinitions"); - - qualityDefinitions.Should().HaveCount(2); - qualityDefinitions.First(v => v.Quality == 1).MaxSize.Should().Be(100); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs deleted file mode 100644 index 655b717ee..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/085_expand_transmission_urlbaseFixture.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class expand_transmission_urlbaseFixture : MigrationTest - { - [Test] - public void should_not_fail_if_no_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Deluge", - Implementation = "Deluge", - Settings = new DelugeSettings85 - { - Host = "127.0.0.1", - TvCategory = "abc", - UrlBase = "/my/" - }.ToJson(), - ConfigContract = "DelugeSettings" - }); - }); - - var items = db.Query("SELECT * FROM DownloadClients"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().UrlBase.Should().Be("/my/"); - } - - [Test] - public void should_be_updated_for_transmission() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new TransmissionSettings81 - { - Host = "127.0.0.1", - TvCategory = "abc" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var items = db.Query("SELECT * FROM DownloadClients"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().UrlBase.Should().Be("/transmission/"); - } - - [Test] - public void should_be_append_to_existing_urlbase() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("DownloadClients").Row(new - { - Enable = 1, - Name = "Trans", - Implementation = "Transmission", - Settings = new TransmissionSettings81 - { - Host = "127.0.0.1", - TvCategory = "abc", - UrlBase = "/my/url/" - }.ToJson(), - ConfigContract = "TransmissionSettings" - }); - }); - - var items = db.Query("SELECT * FROM DownloadClients"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().UrlBase.Should().Be("/my/url/transmission/"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs deleted file mode 100644 index a478ef5d4..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/086_pushbullet_device_idsFixture.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class pushbullet_device_idsFixture : MigrationTest - { - [Test] - public void should_not_fail_if_no_pushbullet() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "Pushover", - Implementation = "Pushover", - Settings = "{}", - ConfigContract = "PushoverSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - } - - [Test] - public void should_not_fail_if_deviceId_is_not_set() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "PushBullet", - Implementation = "PushBullet", - Settings = new - { - ApiKey = "my_api_key" - }.ToJson(), - ConfigContract = "PushBulletSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - } - - [Test] - public void should_add_deviceIds_setting_matching_deviceId() - { - var deviceId = "device_id"; - - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "PushBullet", - Implementation = "PushBullet", - Settings = new - { - ApiKey = "my_api_key", - DeviceId = deviceId - }.ToJson(), - ConfigContract = "PushBulletSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().DeviceIds.First().Should().Be(deviceId); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs deleted file mode 100644 index 37679998c..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/088_pushbullet_devices_channels_listFixture.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class pushbullet_devices_channels_listFixture : MigrationTest - { - [Test] - public void should_convert_comma_separted_string_to_list() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Notifications").Row(new - { - OnGrab = false, - OnDownload = false, - OnUpgrade = false, - Name = "PushBullet", - Implementation = "PushBullet", - Settings = new - { - ApiKey = "my_api_key", - ChannelTags = "channel1,channel2" - }.ToJson(), - ConfigContract = "PushBulletSettings" - }); - }); - - var items = db.Query("SELECT * FROM Notifications"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().ChannelTags.Should().HaveCount(2); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs deleted file mode 100644 index 9a73fb50c..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/090_update_kickass_urlFixture.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class update_kickass_url_migration_fixture : MigrationTest - { - [TestCase("http://kickass.so")] - [TestCase("https://kickass.so")] - [TestCase("http://kickass.to")] - [TestCase("https://kickass.to")] - [TestCase("http://kat.cr")] - - // [TestCase("HTTP://KICKASS.SO")] Not sure if there is an easy way to do this, not sure if worth it. - public void should_replace_old_url(string oldUrl) - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Indexers").Row(new - { - Name = "Kickass_wrong_url", - Implementation = "KickassTorrents", - Settings = new KickassTorrentsSettings90 - { - BaseUrl = oldUrl - }.ToJson(), - ConfigContract = "KickassTorrentsSettings" - }); - }); - - var items = db.Query("SELECT * FROM Indexers"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().BaseUrl.Should().Be("https://kat.cr"); - } - - [Test] - public void should_not_replace_other_indexers() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Indexers").Row(new - { - Name = "not_kickass", - Implementation = "NotKickassTorrents", - Settings = new KickassTorrentsSettings90 - { - BaseUrl = "kickass.so", - }.ToJson(), - ConfigContract = "KickassTorrentsSettings" - }); - }); - - var items = db.Query("SELECT * FROM Indexers"); - - items.Should().HaveCount(1); - items.First().Settings.ToObject().BaseUrl.Should().Be("kickass.so"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs deleted file mode 100644 index f72d950f0..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/099_extra_and_subtitle_filesFixture.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class metadata_files_extensionFixture : MigrationTest - { - [Test] - public void should_set_extension_using_relative_path() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - RelativePath = "banner.jpg", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 3, - Consumer = "XbmcMetadata" - }); - - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01.jpg", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 5, - Consumer = "XbmcMetadata" - }); - - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - RelativePath = "Series Title", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 3, - Consumer = "RoksboxMetadata" - }); - }); - - var items = db.Query("SELECT * FROM MetadataFiles"); - - items.Should().HaveCount(2); - items.First().Extension.Should().Be(".jpg"); - items.Last().Extension.Should().Be(".jpg"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs deleted file mode 100644 index 8e5562824..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/101_add_ultrahd_quality_in_profilesFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class add_ultrahd_quality_in_profilesFixture : MigrationTest - { - [Test] - public void should_add_ultrahd_to_old_profile() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("Profiles").Row(new - { - Id = 0, - Name = "SDTV", - Cutoff = 1, - Items = "[ { \"quality\": 1, \"allowed\": true } ]", - Language = 1 - }); - }); - - var profiles = db.Query("SELECT Items FROM Profiles LIMIT 1"); - - var items = profiles.First().Items; - items.Should().HaveCount(4); - items.Select(v => v.Quality).Should().BeEquivalentTo(1, 16, 18, 19); - items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs deleted file mode 100644 index 86905df18..000000000 --- a/src/NzbDrone.Core.Test/Datastore/Migration/103_fix_metadata_file_extensionsFixture.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Linq; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Datastore.Migration; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore.Migration -{ - [TestFixture] - public class fix_metadata_file_extensionsFixture : MigrationTest - { - [Test] - public void should_fix_extension_when_relative_path_contained_multiple_periods() - { - var db = WithMigrationTestDb(c => - { - c.Insert.IntoTable("MetadataFiles").Row(new - { - SeriesId = 1, - SeasonNumber = 1, - EpisodeFileId = 1, - RelativePath = "Series.Title.S01E01.jpg", - LastUpdated = "2016-05-30 20:23:02.3725923", - Type = 5, - Consumer = "XbmcMetadata", - Extension = ".S01E01.jpg" - }); - }); - - var items = db.Query("SELECT * FROM MetadataFiles"); - - items.Should().HaveCount(1); - items.First().Extension.Should().Be(".jpg"); - } - } -} diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/156_add_download_client_priorityFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/156_add_download_client_priorityFixture.cs index a79d87995..7f6c05671 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/156_add_download_client_priorityFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/156_add_download_client_priorityFixture.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 1, Name = "Deluge", Implementation = "Deluge", - Settings = new DelugeSettings85 + Settings = new DelugeSettings156 { Host = "127.0.0.1", TvCategory = "abc", @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 1, Name = "Deluge", Implementation = "Deluge", - Settings = new DelugeSettings85 + Settings = new DelugeSettings156 { Host = "127.0.0.1", TvCategory = "abc", @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 1, Name = "Deluge2", Implementation = "Deluge", - Settings = new DelugeSettings85 + Settings = new DelugeSettings156 { Host = "127.0.0.1", TvCategory = "abc", @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 1, Name = "sab", Implementation = "Sabnzbd", - Settings = new SabnzbdSettings81 + Settings = new SabnzbdSettings156 { Host = "127.0.0.1", TvCategory = "abc" @@ -98,7 +98,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 0, Name = "Deluge", Implementation = "Deluge", - Settings = new DelugeSettings85 + Settings = new DelugeSettings156 { Host = "127.0.0.1", TvCategory = "abc", @@ -110,7 +110,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 0, Name = "Deluge2", Implementation = "Deluge", - Settings = new DelugeSettings85 + Settings = new DelugeSettings156 { Host = "127.0.0.1", TvCategory = "abc", @@ -122,7 +122,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration Enable = 0, Name = "sab", Implementation = "Sabnzbd", - Settings = new SabnzbdSettings81 + Settings = new SabnzbdSettings156 { Host = "127.0.0.1", TvCategory = "abc" diff --git a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs index 44f28ce92..a3c9140be 100644 --- a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs +++ b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs @@ -17,10 +17,10 @@ namespace NzbDrone.Core.Datastore.Migration Create.TableForModel("Series") .WithColumn("TvdbId").AsInt32().Unique() - .WithColumn("TvRageId").AsInt32().Unique() - .WithColumn("ImdbId").AsString().Unique() + .WithColumn("TvRageId").AsInt32() + .WithColumn("ImdbId").AsString().Nullable() .WithColumn("Title").AsString() - .WithColumn("TitleSlug").AsString().Unique() + .WithColumn("TitleSlug").AsString().Nullable() .WithColumn("CleanTitle").AsString() .WithColumn("Status").AsInt32() .WithColumn("Overview").AsString().Nullable() @@ -28,18 +28,27 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Images").AsString() .WithColumn("Path").AsString() .WithColumn("Monitored").AsBoolean() - .WithColumn("QualityProfileId").AsInt32() .WithColumn("SeasonFolder").AsBoolean() .WithColumn("LastInfoSync").AsDateTime().Nullable() .WithColumn("LastDiskSync").AsDateTime().Nullable() .WithColumn("Runtime").AsInt32() .WithColumn("SeriesType").AsInt32() - .WithColumn("BacklogSetting").AsInt32() .WithColumn("Network").AsString().Nullable() - .WithColumn("CustomStartDate").AsDateTime().Nullable() .WithColumn("UseSceneNumbering").AsBoolean() .WithColumn("FirstAired").AsDateTime().Nullable() - .WithColumn("NextAiring").AsDateTime().Nullable(); + .WithColumn("NextAiring").AsDateTime().Nullable() + .WithColumn("Year").AsInt32().Nullable() + .WithColumn("Seasons").AsString().Nullable() + .WithColumn("Actors").AsString().Nullable() + .WithColumn("Ratings").AsString().Nullable() + .WithColumn("Genres").AsString().Nullable() + .WithColumn("Certification").AsString().Nullable() + .WithColumn("SortTitle").AsString().Nullable() + .WithColumn("ProfileId").AsInt32().Nullable() + .WithColumn("Tags").AsString().Nullable() + .WithColumn("Added").AsDateTime().Nullable() + .WithColumn("AddOptions").AsString().Nullable() + .WithColumn("TvMazeId").AsInt32().WithDefaultValue(0); Create.TableForModel("Movies") .WithColumn("ImdbId").AsString().Unique() @@ -66,101 +75,236 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Certification").AsString().Nullable() .WithColumn("AddOptions").AsString().Nullable(); - Create.TableForModel("Seasons") - .WithColumn("SeriesId").AsInt32() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("Ignored").AsBoolean(); - Create.TableForModel("Episodes") - .WithColumn("TvDbEpisodeId").AsInt32().Unique() .WithColumn("SeriesId").AsInt32() .WithColumn("SeasonNumber").AsInt32() .WithColumn("EpisodeNumber").AsInt32() .WithColumn("Title").AsString().Nullable() .WithColumn("Overview").AsString().Nullable() - .WithColumn("Ignored").AsBoolean().Nullable() .WithColumn("EpisodeFileId").AsInt32().Nullable() - .WithColumn("AirDate").AsDateTime().Nullable() + .WithColumn("AirDate").AsString().Nullable() + .WithColumn("AirDateUtc").AsDateTime().Nullable() .WithColumn("AbsoluteEpisodeNumber").AsInt32().Nullable() .WithColumn("SceneAbsoluteEpisodeNumber").AsInt32().Nullable() .WithColumn("SceneSeasonNumber").AsInt32().Nullable() - .WithColumn("SceneEpisodeNumber").AsInt32().Nullable(); + .WithColumn("SceneEpisodeNumber").AsInt32().Nullable() + .WithColumn("Monitored").AsBoolean().Nullable() // Nullable? + .WithColumn("Ratings").AsString().Nullable() + .WithColumn("Images").AsString().Nullable() + .WithColumn("UnverifiedSceneNumbering").AsBoolean().WithDefaultValue(false); Create.TableForModel("EpisodeFiles") - .WithColumn("SeriesId").AsInt32() - .WithColumn("Path").AsString().Unique() - .WithColumn("Quality").AsString() - .WithColumn("Size").AsInt64() - .WithColumn("DateAdded").AsDateTime() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("SceneName").AsString().Nullable() - .WithColumn("ReleaseGroup").AsString().Nullable(); + .WithColumn("SeriesId").AsInt32() + .WithColumn("Quality").AsString() + .WithColumn("Size").AsInt64() + .WithColumn("DateAdded").AsDateTime() + .WithColumn("SeasonNumber").AsInt32() + .WithColumn("SceneName").AsString().Nullable() + .WithColumn("ReleaseGroup").AsString().Nullable() + .WithColumn("MediaInfo").AsString().Nullable() + .WithColumn("RelativePath").AsString().Nullable(); Create.TableForModel("History") - .WithColumn("EpisodeId").AsInt32() - .WithColumn("SeriesId").AsInt32() - .WithColumn("NzbTitle").AsString() - .WithColumn("Date").AsDateTime() - .WithColumn("Quality").AsString() - .WithColumn("Indexer").AsString() - .WithColumn("NzbInfoUrl").AsString().Nullable() - .WithColumn("ReleaseGroup").AsString().Nullable() - .WithColumn("MovieId").AsInt32().WithDefaultValue(0); + .WithColumn("EpisodeId").AsInt32() + .WithColumn("SeriesId").AsInt32() + .WithColumn("SourceTitle").AsString() + .WithColumn("Date").AsDateTime() + .WithColumn("Quality").AsString() + .WithColumn("Data").AsString() + .WithColumn("EventType").AsInt32().Nullable() + .WithColumn("DownloadId").AsString().Nullable().Indexed(); Create.TableForModel("Notifications") - .WithColumn("Name").AsString() - .WithColumn("OnGrab").AsBoolean() - .WithColumn("OnDownload").AsBoolean() - .WithColumn("Settings").AsString() - .WithColumn("Implementation").AsString(); + .WithColumn("Name").AsString() + .WithColumn("OnGrab").AsBoolean() + .WithColumn("OnDownload").AsBoolean() + .WithColumn("Settings").AsString() + .WithColumn("Implementation").AsString() + .WithColumn("ConfigContract").AsString().Nullable() + .WithColumn("OnUpgrade").AsBoolean().Nullable() + .WithColumn("Tags").AsString().Nullable() + .WithColumn("OnRename").AsBoolean().NotNullable(); Create.TableForModel("ScheduledTasks") - .WithColumn("TypeName").AsString().Unique() - .WithColumn("Interval").AsInt32() - .WithColumn("LastExecution").AsDateTime(); + .WithColumn("TypeName").AsString().Unique() + .WithColumn("Interval").AsInt32() + .WithColumn("LastExecution").AsDateTime(); Create.TableForModel("Indexers") - .WithColumn("Enable").AsBoolean() - .WithColumn("Name").AsString().Unique() - .WithColumn("Implementation").AsString() - .WithColumn("Settings").AsString().Nullable(); - - Create.TableForModel("QualityProfiles") - .WithColumn("Name").AsString().Unique() - .WithColumn("Cutoff").AsInt32() - .WithColumn("Allowed").AsString(); - - Create.TableForModel("QualitySizes") - .WithColumn("QualityId").AsInt32().Unique() - .WithColumn("Name").AsString().Unique() - .WithColumn("MinSize").AsInt32() - .WithColumn("MaxSize").AsInt32(); + .WithColumn("Name").AsString().Unique() + .WithColumn("Implementation").AsString() + .WithColumn("Settings").AsString().Nullable() + .WithColumn("ConfigContract").AsString().Nullable() + .WithColumn("EnableRss").AsBoolean().Nullable() + .WithColumn("EnableSearch").AsBoolean().Nullable(); + + Create.TableForModel("Profiles") + .WithColumn("Name").AsString().Unique() + .WithColumn("Cutoff").AsInt32() + .WithColumn("Items").AsString().NotNullable() + .WithColumn("Language").AsInt32().Nullable(); + + Execute.Sql("UPDATE Profiles SET Language = 1"); Create.TableForModel("SceneMappings") - .WithColumn("CleanTitle").AsString() - .WithColumn("SceneName").AsString() - .WithColumn("TvdbId").AsInt32() - .WithColumn("SeasonNumber").AsInt32(); + .WithColumn("TvdbId").AsInt32() + .WithColumn("SeasonNumber").AsInt32().Nullable() + .WithColumn("SearchTerm").AsString() + .WithColumn("ParseTerm").AsString() + .WithColumn("Title").AsString().Nullable() + .WithColumn("Type").AsString().Nullable() + .WithColumn("SceneSeasonNumber").AsInt32().Nullable(); Create.TableForModel("NamingConfig") - .WithColumn("UseSceneName").AsBoolean() - .WithColumn("Separator").AsString() - .WithColumn("NumberStyle").AsInt32() - .WithColumn("IncludeSeriesTitle").AsBoolean() - .WithColumn("MultiEpisodeStyle").AsInt32() - .WithColumn("IncludeEpisodeTitle").AsBoolean() - .WithColumn("IncludeQuality").AsBoolean() - .WithColumn("ReplaceSpaces").AsBoolean() - .WithColumn("SeasonFolderFormat").AsString(); + .WithColumn("MultiEpisodeStyle").AsInt32() + .WithColumn("RenameEpisodes").AsBoolean().Nullable() // Set a default - Check Lidarr + .WithColumn("StandardEpisodeFormat").AsString().Nullable() + .WithColumn("DailyEpisodeFormat").AsString().Nullable() + .WithColumn("SeriesFolderFormat").AsString().Nullable() + .WithColumn("SeasonFolderFormat").AsString().Nullable() + .WithColumn("AnimeEpisodeFormat").AsString().Nullable() + .WithColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true); + + Create.TableForModel("Blacklist") + .WithColumn("SeriesId").AsInt32() + .WithColumn("EpisodeIds").AsString() + .WithColumn("SourceTitle").AsString() + .WithColumn("Quality").AsString() + .WithColumn("Date").AsDateTime() + .WithColumn("PublishedDate").AsDateTime().Nullable() + .WithColumn("Size").AsInt64().Nullable() + .WithColumn("Protocol").AsInt32().Nullable() + .WithColumn("Indexer").AsString().Nullable() + .WithColumn("Message").AsString().Nullable() + .WithColumn("TorrentInfoHash").AsString().Nullable(); + + Create.TableForModel("QualityDefinitions") + .WithColumn("Quality").AsInt32().Unique() + .WithColumn("Title").AsString().Unique() + .WithColumn("MinSize").AsDouble().Nullable() + .WithColumn("MaxSize").AsDouble().Nullable(); + + Create.TableForModel("Metadata") + .WithColumn("Enable").AsBoolean().NotNullable() + .WithColumn("Name").AsString().NotNullable() + .WithColumn("Implementation").AsString().NotNullable() + .WithColumn("Settings").AsString().NotNullable() + .WithColumn("ConfigContract").AsString().NotNullable(); + + Create.TableForModel("MetadataFiles") + .WithColumn("SeriesId").AsInt32().NotNullable() + .WithColumn("Consumer").AsString().NotNullable() + .WithColumn("Type").AsInt32().NotNullable() + .WithColumn("RelativePath").AsString().NotNullable() + .WithColumn("LastUpdated").AsDateTime().NotNullable() + .WithColumn("SeasonNumber").AsInt32().Nullable() + .WithColumn("EpisodeFileId").AsInt32().Nullable() + .WithColumn("Added").AsDateTime().Nullable() + .WithColumn("Extension").AsString().NotNullable() + .WithColumn("Hash").AsString().Nullable(); + + Create.TableForModel("DownloadClients") + .WithColumn("Enable").AsBoolean().NotNullable() + .WithColumn("Name").AsString().NotNullable() + .WithColumn("Implementation").AsString().NotNullable() + .WithColumn("Settings").AsString().NotNullable() + .WithColumn("ConfigContract").AsString().NotNullable(); + + Create.TableForModel("PendingReleases") + .WithColumn("SeriesId").AsInt32().WithDefaultValue(0) + .WithColumn("Title").AsString() + .WithColumn("Added").AsDateTime() + .WithColumn("ParsedEpisodeInfo").AsString() + .WithColumn("Release").AsString() + .WithColumn("MovieId").AsInt32().WithDefaultValue(0); + + Create.TableForModel("RemotePathMappings") + .WithColumn("Host").AsString() + .WithColumn("RemotePath").AsString() + .WithColumn("LocalPath").AsString(); + + Create.TableForModel("Tags") + .WithColumn("Label").AsString().Unique(); + + Create.TableForModel("Restrictions") + .WithColumn("Required").AsString().Nullable() + .WithColumn("Preferred").AsString().Nullable() + .WithColumn("Ignored").AsString().Nullable() + .WithColumn("Tags").AsString().NotNullable(); + + Create.TableForModel("DelayProfiles") + .WithColumn("EnableUsenet").AsBoolean().NotNullable() + .WithColumn("EnableTorrent").AsBoolean().NotNullable() + .WithColumn("PreferredProtocol").AsInt32().NotNullable() + .WithColumn("UsenetDelay").AsInt32().NotNullable() + .WithColumn("TorrentDelay").AsInt32().NotNullable() + .WithColumn("Order").AsInt32().NotNullable() + .WithColumn("Tags").AsString().NotNullable(); + + Insert.IntoTable("DelayProfiles").Row(new + { + EnableUsenet = 1, + EnableTorrent = 1, + PreferredProtocol = 1, + UsenetDelay = 0, + TorrentDelay = 0, + Order = int.MaxValue, + Tags = "[]" + }); + + Create.TableForModel("Users") + .WithColumn("Identifier").AsString().NotNullable().Unique() + .WithColumn("Username").AsString().NotNullable().Unique() + .WithColumn("Password").AsString().NotNullable(); + + Create.TableForModel("Commands") + .WithColumn("Name").AsString().NotNullable() + .WithColumn("Body").AsString().NotNullable() + .WithColumn("Priority").AsInt32().NotNullable() + .WithColumn("Status").AsInt32().NotNullable() + .WithColumn("QueuedAt").AsDateTime().NotNullable() + .WithColumn("StartedAt").AsDateTime().Nullable() + .WithColumn("EndedAt").AsDateTime().Nullable() + .WithColumn("Duration").AsString().Nullable() + .WithColumn("Exception").AsString().Nullable() + .WithColumn("Trigger").AsInt32().NotNullable(); + + Create.TableForModel("IndexerStatus") + .WithColumn("IndexerId").AsInt32().NotNullable().Unique() + .WithColumn("InitialFailure").AsDateTime().Nullable() + .WithColumn("MostRecentFailure").AsDateTime().Nullable() + .WithColumn("EscalationLevel").AsInt32().NotNullable() + .WithColumn("DisabledTill").AsDateTime().Nullable() + .WithColumn("LastRssSyncReleaseInfo").AsString().Nullable(); + + Create.TableForModel("ExtraFiles") + .WithColumn("SeriesId").AsInt32().NotNullable() + .WithColumn("SeasonNumber").AsInt32().NotNullable() + .WithColumn("EpisodeFileId").AsInt32().NotNullable() + .WithColumn("RelativePath").AsString().NotNullable() + .WithColumn("Extension").AsString().NotNullable() + .WithColumn("Added").AsDateTime().NotNullable() + .WithColumn("LastUpdated").AsDateTime().NotNullable(); + + Create.TableForModel("SubtitleFiles") + .WithColumn("SeriesId").AsInt32().NotNullable() + .WithColumn("SeasonNumber").AsInt32().NotNullable() + .WithColumn("EpisodeFileId").AsInt32().NotNullable() + .WithColumn("RelativePath").AsString().NotNullable() + .WithColumn("Extension").AsString().NotNullable() + .WithColumn("Added").AsDateTime().NotNullable() + .WithColumn("LastUpdated").AsDateTime().NotNullable() + .WithColumn("Language").AsInt32().NotNullable(); + + Create.Index().OnTable("History").OnColumn("Date"); } protected override void LogDbUpgrade() { Create.TableForModel("Logs") .WithColumn("Message").AsString() - .WithColumn("Time").AsDateTime() + .WithColumn("Time").AsDateTime().Indexed() .WithColumn("Logger").AsString() - .WithColumn("Method").AsString().Nullable() .WithColumn("Exception").AsString().Nullable() .WithColumn("ExceptionType").AsString().Nullable() .WithColumn("Level").AsString(); diff --git a/src/NzbDrone.Core/Datastore/Migration/002_103_sonarr_squashed.cs b/src/NzbDrone.Core/Datastore/Migration/002_103_sonarr_squashed.cs new file mode 100644 index 000000000..5cbe3db10 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/002_103_sonarr_squashed.cs @@ -0,0 +1,7 @@ +namespace NzbDrone.Core.Datastore.Migration +{ + //Migrations 002 - 103 were squashed in to 001, do not use these migration numbers, versions will be present in V1 migrated Radarr DBs + public class sonarr_squashed + { + } +} diff --git a/src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs b/src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs deleted file mode 100644 index 6fc6a6cd3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/002_remove_tvrage_imdb_unique_constraint.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(2)] - public class remove_tvrage_imdb_unique_constraint : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Index().OnTable("Series").OnColumn("TvRageId"); - Delete.Index().OnTable("Series").OnColumn("ImdbId"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs b/src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs deleted file mode 100644 index a19bae93c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/003_remove_clean_title_from_scene_mapping.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(3)] - public class remove_renamed_scene_mapping_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Table("SceneMappings"); - - Create.TableForModel("SceneMappings") - .WithColumn("TvdbId").AsInt32() - .WithColumn("SeasonNumber").AsInt32() - .WithColumn("SearchTerm").AsString() - .WithColumn("ParseTerm").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs b/src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs deleted file mode 100644 index 0eaf4da5b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/004_updated_history.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(4)] - public class updated_history : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Table("History"); - - Create.TableForModel("History") - .WithColumn("EpisodeId").AsInt32() - .WithColumn("SeriesId").AsInt32() - .WithColumn("SourceTitle").AsString() - .WithColumn("Date").AsDateTime() - .WithColumn("Quality").AsString() - .WithColumn("Data").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs b/src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs deleted file mode 100644 index bead4c96f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(5)] - public class added_eventtype_to_history : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("History") - .AddColumn("EventType") - .AsInt32() - .Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs b/src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs deleted file mode 100644 index add668fdc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/006_add_index_to_log_time.cs +++ /dev/null @@ -1,23 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(6)] - public class add_index_to_log_time : NzbDroneMigrationBase - { - protected override void LogDbUpgrade() - { - Delete.Table("Logs"); - - Create.TableForModel("Logs") - .WithColumn("Message").AsString() - .WithColumn("Time").AsDateTime().Indexed() - .WithColumn("Logger").AsString() - .WithColumn("Method").AsString().Nullable() - .WithColumn("Exception").AsString().Nullable() - .WithColumn("ExceptionType").AsString().Nullable() - .WithColumn("Level").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs b/src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs deleted file mode 100644 index 3fc4abef9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(7)] - public class add_renameEpisodes_to_naming : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig") - .AddColumn("RenameEpisodes") - .AsBoolean() - .Nullable(); - - Execute.Sql("UPDATE NamingConfig SET RenameEpisodes =~ UseSceneName"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs b/src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs deleted file mode 100644 index 19e16242c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/008_remove_backlog.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(8)] - public class remove_backlog : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("BacklogSetting").FromTable("Series"); - Delete.Column("UseSceneName").FromTable("NamingConfig"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs b/src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs deleted file mode 100644 index bdc0c54e5..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/009_fix_renameEpisodes.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(9)] - public class fix_rename_episodes : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("SeasonFolderFormat").FromTable("NamingConfig"); - - Execute.Sql("UPDATE NamingConfig SET RenameEpisodes = 1 WHERE RenameEpisodes = -1"); - Execute.Sql("UPDATE NamingConfig SET RenameEpisodes = 0 WHERE RenameEpisodes = -2"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs b/src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs deleted file mode 100644 index a64f44877..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/010_add_monitored.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(10)] - public class add_monitored : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("Monitored").AsBoolean().Nullable(); - Alter.Table("Seasons").AddColumn("Monitored").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Episodes SET Monitored = 1 WHERE Ignored = 0"); - Execute.Sql("UPDATE Episodes SET Monitored = 0 WHERE Ignored = 1"); - - Execute.Sql("UPDATE Seasons SET Monitored = 1 WHERE Ignored = 0"); - Execute.Sql("UPDATE Seasons SET Monitored = 0 WHERE Ignored = 1"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs b/src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs deleted file mode 100644 index 193b25094..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(11)] - public class remove_ignored : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Ignored").FromTable("Seasons"); - Delete.Column("Ignored").FromTable("Episodes"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs b/src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs deleted file mode 100644 index 8b19f1a3f..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/012_remove_custom_start_date.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(12)] - public class remove_custom_start_date : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("CustomStartDate").FromTable("Series"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs b/src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs deleted file mode 100644 index ece91b397..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(13)] - public class add_air_date_utc : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("AirDateUtc").AsDateTime().Nullable(); - - Execute.Sql("UPDATE Episodes SET AirDateUtc = AirDate"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs b/src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs deleted file mode 100644 index 00af970b9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/014_drop_air_date.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(14)] - public class drop_air_date : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("AirDate").FromTable("Episodes"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs b/src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs deleted file mode 100644 index 7638e6df5..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/015_add_air_date_as_string.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(15)] - public class add_air_date_as_string : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("AirDate").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs b/src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs deleted file mode 100644 index 7a2c50e71..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/016_updated_imported_history_item.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(16)] - public class updated_imported_history_item : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql(@"UPDATE HISTORY SET Data = replace( Data, '""Path""', '""ImportedPath""' ) WHERE EventType=3"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs b/src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs deleted file mode 100644 index e2e3a21d6..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/017_reset_scene_names.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(17)] - public class reset_scene_names : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - //we were storing new file name as scene name. - Execute.Sql(@"UPDATE EpisodeFiles SET SceneName = NULL where SceneName != NULL"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs b/src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs deleted file mode 100644 index dbe11a6a9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/018_remove_duplicates.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(18)] - public class remove_duplicates : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(RemoveDuplicates); - } - - private void RemoveDuplicates(IDbConnection conn, IDbTransaction tran) - { - RemoveDuplicateSeries(conn, tran, "TvdbId"); - RemoveDuplicateSeries(conn, tran, "TitleSlug"); - - var duplicatedEpisodes = GetDuplicates(conn, tran, "Episodes", "TvDbEpisodeId"); - - foreach (var duplicate in duplicatedEpisodes) - { - foreach (var episodeId in duplicate.OrderBy(c => c.Key).Skip(1).Select(c => c.Key)) - { - RemoveEpisodeRows(conn, tran, episodeId); - } - } - } - - private IEnumerable>> GetDuplicates(IDbConnection conn, IDbTransaction tran, string tableName, string columnName) - { - var getDuplicates = conn.CreateCommand(); - getDuplicates.Transaction = tran; - getDuplicates.CommandText = string.Format("select id, {0} from {1}", columnName, tableName); - - var result = new List>(); - - using (var reader = getDuplicates.ExecuteReader()) - { - while (reader.Read()) - { - result.Add(new KeyValuePair(reader.GetInt32(0), (T)Convert.ChangeType(reader[1], typeof(T)))); - } - } - - return result.GroupBy(c => c.Value).Where(g => g.Count() > 1); - } - - private void RemoveDuplicateSeries(IDbConnection conn, IDbTransaction tran, string field) - { - var duplicatedSeries = GetDuplicates(conn, tran, "Series", field); - - foreach (var duplicate in duplicatedSeries) - { - foreach (var seriesId in duplicate.OrderBy(c => c.Key).Skip(1).Select(c => c.Key)) - { - RemoveSeriesRows(conn, tran, seriesId); - } - } - } - - private void RemoveSeriesRows(IDbConnection conn, IDbTransaction tran, int seriesId) - { - var deleteCmd = conn.CreateCommand(); - deleteCmd.Transaction = tran; - - deleteCmd.CommandText = string.Format("DELETE FROM Series WHERE Id = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM Episodes WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM Seasons WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM History WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM EpisodeFiles WHERE SeriesId = {0}", seriesId.ToString()); - deleteCmd.ExecuteNonQuery(); - } - - private void RemoveEpisodeRows(IDbConnection conn, IDbTransaction tran, int episodeId) - { - var deleteCmd = conn.CreateCommand(); - deleteCmd.Transaction = tran; - - deleteCmd.CommandText = string.Format("DELETE FROM Episodes WHERE Id = {0}", episodeId.ToString()); - deleteCmd.ExecuteNonQuery(); - - deleteCmd.CommandText = string.Format("DELETE FROM History WHERE EpisodeId = {0}", episodeId.ToString()); - deleteCmd.ExecuteNonQuery(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs b/src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs deleted file mode 100644 index 776371f94..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/019_restore_unique_constraints.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(19)] - public class restore_unique_constraints : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - // During an earlier version of drone, the indexes weren't recreated during alter table. - Execute.Sql("DROP INDEX IF EXISTS \"IX_Series_TvdbId\""); - Execute.Sql("DROP INDEX IF EXISTS \"IX_Series_TitleSlug\""); - Execute.Sql("DROP INDEX IF EXISTS \"IX_Episodes_TvDbEpisodeId\""); - - Create.Index().OnTable("Series").OnColumn("TvdbId").Unique(); - Create.Index().OnTable("Series").OnColumn("TitleSlug").Unique(); - Create.Index().OnTable("Episodes").OnColumn("TvDbEpisodeId").Unique(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs b/src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs deleted file mode 100644 index bfbf78a77..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/020_add_year_and_seasons_to_series.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(20)] - public class add_year_and_seasons_to_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("Year").AsInt32().Nullable(); - Alter.Table("Series").AddColumn("Seasons").AsString().Nullable(); - - Execute.WithConnection(ConvertSeasons); - } - - private void ConvertSeasons(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand allSeriesCmd = conn.CreateCommand()) - { - allSeriesCmd.Transaction = tran; - allSeriesCmd.CommandText = @"SELECT Id FROM Series"; - using (IDataReader allSeriesReader = allSeriesCmd.ExecuteReader()) - { - while (allSeriesReader.Read()) - { - int seriesId = allSeriesReader.GetInt32(0); - var seasons = new List(); - - using (IDbCommand seasonsCmd = conn.CreateCommand()) - { - seasonsCmd.Transaction = tran; - seasonsCmd.CommandText = string.Format(@"SELECT SeasonNumber, Monitored FROM Seasons WHERE SeriesId = {0}", seriesId); - - using (IDataReader seasonReader = seasonsCmd.ExecuteReader()) - { - while (seasonReader.Read()) - { - int seasonNumber = seasonReader.GetInt32(0); - bool monitored = seasonReader.GetBoolean(1); - - if (seasonNumber == 0) - { - monitored = false; - } - - seasons.Add(new { seasonNumber, monitored }); - } - } - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE Series SET Seasons = '{0}' WHERE Id = {1}", seasons.ToJson(), seriesId); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs b/src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs deleted file mode 100644 index d2527c755..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/021_drop_seasons_table.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(21)] - public class drop_seasons_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Table("Seasons"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs b/src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs deleted file mode 100644 index ea1908901..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/022_move_indexer_to_generic_provider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(22)] - public class move_indexer_to_generic_provider : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Indexers").AddColumn("ConfigContract").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs b/src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs deleted file mode 100644 index 1a40a5a26..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/023_add_config_contract_to_indexers.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(23)] - public class add_config_contract_to_indexers : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Indexers").Set(new { ConfigContract = "NewznabSettings" }).Where(new { Implementation = "Newznab" }); - Update.Table("Indexers").Set(new { ConfigContract = "OmgwtfnzbsSettings" }).Where(new { Implementation = "Omgwtfnzbs" }); - Update.Table("Indexers").Set(new { ConfigContract = "NullConfig" }).Where(new { Implementation = "Wombles" }); - Update.Table("Indexers").Set(new { ConfigContract = "NullConfig" }).Where(new { Implementation = "Eztv" }); - - Delete.FromTable("Indexers").IsNull("ConfigContract"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs b/src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs deleted file mode 100644 index c723f462c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/024_drop_tvdb_episodeid.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(24)] - public class drop_tvdb_episodeid : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("TvDbEpisodeId").FromTable("Episodes"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs b/src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs deleted file mode 100644 index 1937f76eb..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/025_move_notification_to_generic_provider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(25)] - public class move_notification_to_generic_provider : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Notifications").AddColumn("ConfigContract").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs b/src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs deleted file mode 100644 index 8eb24daae..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/026_add_config_contract_to_notifications.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(26)] - public class add_config_contract_to_notifications : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Notifications").Set(new { ConfigContract = "EmailSettings" }).Where(new { Implementation = "Email" }); - Update.Table("Notifications").Set(new { ConfigContract = "GrowlSettings" }).Where(new { Implementation = "Growl" }); - Update.Table("Notifications").Set(new { ConfigContract = "NotifyMyAndroidSettings" }).Where(new { Implementation = "NotifyMyAndroid" }); - Update.Table("Notifications").Set(new { ConfigContract = "PlexClientSettings" }).Where(new { Implementation = "PlexClient" }); - Update.Table("Notifications").Set(new { ConfigContract = "PlexServerSettings" }).Where(new { Implementation = "PlexServer" }); - Update.Table("Notifications").Set(new { ConfigContract = "ProwlSettings" }).Where(new { Implementation = "Prowl" }); - Update.Table("Notifications").Set(new { ConfigContract = "PushBulletSettings" }).Where(new { Implementation = "PushBullet" }); - Update.Table("Notifications").Set(new { ConfigContract = "PushoverSettings" }).Where(new { Implementation = "Pushover" }); - Update.Table("Notifications").Set(new { ConfigContract = "XbmcSettings" }).Where(new { Implementation = "Xbmc" }); - - Delete.FromTable("Notifications").IsNull("ConfigContract"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs b/src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs deleted file mode 100644 index daa6699bc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/027_fix_omgwtfnzbs.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(27)] - public class fix_omgwtfnzbs : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Indexers") - .Set(new { ConfigContract = "OmgwtfnzbsSettings" }) - .Where(new { Implementation = "Omgwtfnzbs" }); - - Update.Table("Indexers") - .Set(new { Settings = "{}" }) - .Where(new { Implementation = "Omgwtfnzbs", Settings = (string)null }); - - Update.Table("Indexers") - .Set(new { Settings = "{}" }) - .Where(new { Implementation = "Omgwtfnzbs", Settings = "" }); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs b/src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs deleted file mode 100644 index 0514c9689..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/028_add_blacklist_table.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(28)] - public class add_blacklist_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Blacklist") - .WithColumn("SeriesId").AsInt32() - .WithColumn("EpisodeIds").AsString() - .WithColumn("SourceTitle").AsString() - .WithColumn("Quality").AsString() - .WithColumn("Date").AsDateTime(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs deleted file mode 100644 index ca8c3e2c1..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/029_add_formats_to_naming_config.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(29)] - public class add_formats_to_naming_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("StandardEpisodeFormat").AsString().Nullable(); - Alter.Table("NamingConfig").AddColumn("DailyEpisodeFormat").AsString().Nullable(); - - Execute.WithConnection(ConvertConfig); - } - - private void ConvertConfig(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand namingConfigCmd = conn.CreateCommand()) - { - namingConfigCmd.Transaction = tran; - namingConfigCmd.CommandText = @"SELECT * FROM NamingConfig LIMIT 1"; - using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader()) - { - var separatorIndex = namingConfigReader.GetOrdinal("Separator"); - var numberStyleIndex = namingConfigReader.GetOrdinal("NumberStyle"); - var includeSeriesTitleIndex = namingConfigReader.GetOrdinal("IncludeSeriesTitle"); - var includeEpisodeTitleIndex = namingConfigReader.GetOrdinal("IncludeEpisodeTitle"); - var includeQualityIndex = namingConfigReader.GetOrdinal("IncludeQuality"); - var replaceSpacesIndex = namingConfigReader.GetOrdinal("ReplaceSpaces"); - - while (namingConfigReader.Read()) - { - var separator = namingConfigReader.GetString(separatorIndex); - var numberStyle = namingConfigReader.GetInt32(numberStyleIndex); - var includeSeriesTitle = namingConfigReader.GetBoolean(includeSeriesTitleIndex); - var includeEpisodeTitle = namingConfigReader.GetBoolean(includeEpisodeTitleIndex); - var includeQuality = namingConfigReader.GetBoolean(includeQualityIndex); - var replaceSpaces = namingConfigReader.GetBoolean(replaceSpacesIndex); - - //Output settings - var seriesTitlePattern = ""; - var episodeTitlePattern = ""; - var dailyEpisodePattern = "{Air-Date}"; - var qualityFormat = " [{Quality Title}]"; - - if (includeSeriesTitle) - { - if (replaceSpaces) - { - seriesTitlePattern = "{Series.Title}"; - } - else - { - seriesTitlePattern = "{Series Title}"; - } - - seriesTitlePattern += separator; - } - - if (includeEpisodeTitle) - { - episodeTitlePattern = separator; - - if (replaceSpaces) - { - episodeTitlePattern += "{Episode.Title}"; - } - else - { - episodeTitlePattern += "{Episode Title}"; - } - } - - var standardEpisodeFormat = string.Format("{0}{1}{2}", - seriesTitlePattern, - GetNumberStyle(numberStyle).Pattern, - episodeTitlePattern); - - var dailyEpisodeFormat = string.Format("{0}{1}{2}", - seriesTitlePattern, - dailyEpisodePattern, - episodeTitlePattern); - - if (includeQuality) - { - if (replaceSpaces) - { - qualityFormat = ".[{Quality.Title}]"; - } - - standardEpisodeFormat += qualityFormat; - dailyEpisodeFormat += qualityFormat; - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE NamingConfig " + - "SET StandardEpisodeFormat = '{0}', " + - "DailyEpisodeFormat = '{1}'", - standardEpisodeFormat, - dailyEpisodeFormat); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private static readonly List NumberStyles = new List - { - new - { - Id = 0, - Name = "1x05", - Pattern = "{season}x{episode:00}", - EpisodeSeparator = "x" - }, - new - { - Id = 1, - Name = "01x05", - Pattern = "{season:00}x{episode:00}", - EpisodeSeparator = "x" - }, - new - { - Id = 2, - Name = "S01E05", - Pattern = "S{season:00}E{episode:00}", - EpisodeSeparator = "E" - }, - new - { - Id = 3, - Name = "s01e05", - Pattern = "s{season:00}e{episode:00}", - EpisodeSeparator = "e" - } - }; - - private static dynamic GetNumberStyle(int id) - { - return NumberStyles.Single(s => s.Id == id); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs deleted file mode 100644 index 185a53a19..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/030_add_season_folder_format_to_naming_config.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(30)] - public class add_season_folder_format_to_naming_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("SeasonFolderFormat").AsString().Nullable(); - Execute.WithConnection(ConvertConfig); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'seasonfolderformat'"); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'useseasonfolder'"); - } - - private void ConvertConfig(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand namingConfigCmd = conn.CreateCommand()) - { - namingConfigCmd.Transaction = tran; - namingConfigCmd.CommandText = @"SELECT [Value] FROM Config WHERE [Key] = 'seasonfolderformat'"; - var seasonFormat = "Season {season}"; - - using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader()) - { - while (namingConfigReader.Read()) - { - //only getting one column, so its index is 0 - seasonFormat = namingConfigReader.GetString(0); - - seasonFormat = seasonFormat.Replace("%sn", "{Series Title}") - .Replace("%s.n", "{Series.Title}") - .Replace("%s", "{season}") - .Replace("%0s", "{season:00}") - .Replace("%e", "{episode}") - .Replace("%0e", "{episode:00}"); - } - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE NamingConfig " + - "SET SeasonFolderFormat = '{0}'", - seasonFormat); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs b/src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs deleted file mode 100644 index 90c7571af..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/031_delete_old_naming_config_columns.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(31)] - public class delete_old_naming_config_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Separator") - .Column("NumberStyle") - .Column("IncludeSeriesTitle") - .Column("IncludeEpisodeTitle") - .Column("IncludeQuality") - .Column("ReplaceSpaces") - .FromTable("NamingConfig"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs b/src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs deleted file mode 100644 index 5ecc4e2c0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/032_set_default_release_group.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(32)] - public class set_default_release_group : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE EpisodeFiles SET ReleaseGroup = 'DRONE' WHERE ReleaseGroup IS NULL"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs b/src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs deleted file mode 100644 index edd93183b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/033_add_api_key_to_pushover.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(33)] - public class add_api_key_to_pushover : NzbDroneMigrationBase - { - private const string API_KEY = "yz9b4U215iR4vrKFRfjNXP24NMNPKJ"; - - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdatePushoverSettings); - } - - private void UpdatePushoverSettings(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand selectCommand = conn.CreateCommand()) - { - selectCommand.Transaction = tran; - selectCommand.CommandText = @"SELECT * FROM Notifications WHERE ConfigContract = 'PushoverSettings'"; - - using (IDataReader reader = selectCommand.ExecuteReader()) - { - while (reader.Read()) - { - var idIndex = reader.GetOrdinal("Id"); - var settingsIndex = reader.GetOrdinal("Settings"); - - var id = reader.GetInt32(idIndex); - var settings = Json.Deserialize(reader.GetString(settingsIndex)); - settings.ApiKey = API_KEY; - - //Set priority to high if its currently emergency - if (settings.Priority == 2) - { - settings.Priority = 1; - } - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("UPDATE Notifications " + - "SET Settings = '{0}'" + - "WHERE Id = {1}", - settings.ToJson(), - id); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private class PushoverSettingsForV33 - { - public string ApiKey { get; set; } - public string UserKey { get; set; } - public int Priority { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs b/src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs deleted file mode 100644 index 8eb08798a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/034_remove_series_contraints.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(34)] - public class remove_series_contraints : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series") - .AlterColumn("ImdbId").AsString().Nullable() - .AlterColumn("TitleSlug").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs deleted file mode 100644 index 9423a54f0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/035_add_series_folder_format_to_naming_config.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(35)] - public class add_series_folder_format_to_naming_config : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("SeriesFolderFormat").AsString().Nullable(); - - Execute.Sql("UPDATE NamingConfig SET SeriesFolderFormat = '{Series Title}'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs b/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs deleted file mode 100644 index aa6f5a82c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Converters; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Profiles; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(36)] - public class update_with_quality_converters : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - if (!Schema.Table("QualityProfiles").Column("Items").Exists()) - { - Alter.Table("QualityProfiles").AddColumn("Items").AsString().Nullable(); - } - - Execute.WithConnection(ConvertQualityProfiles); - Execute.WithConnection(ConvertQualityModels); - } - - private void ConvertQualityProfiles(IDbConnection conn, IDbTransaction tran) - { - var qualityProfileItemConverter = new EmbeddedDocumentConverter>(new QualityIntConverter()); - - // Convert 'Allowed' column in QualityProfiles from Json List to Json List (int = Quality) - using (IDbCommand qualityProfileCmd = conn.CreateCommand()) - { - qualityProfileCmd.Transaction = tran; - qualityProfileCmd.CommandText = @"SELECT Id, Allowed FROM QualityProfiles"; - using (IDataReader qualityProfileReader = qualityProfileCmd.ExecuteReader()) - { - while (qualityProfileReader.Read()) - { - var id = qualityProfileReader.GetInt32(0); - var allowedJson = qualityProfileReader.GetString(1); - - var allowed = Json.Deserialize>(allowedJson); - - var items = Quality.DefaultQualityDefinitions.OrderBy(v => v.Weight).Select(v => new ProfileQualityItem { Quality = v.Quality, Allowed = allowed.Contains(v.Quality) }).ToList(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE QualityProfiles SET Items = ? WHERE Id = ?"; - var param = updateCmd.CreateParameter(); - qualityProfileItemConverter.SetValue(param, items); - updateCmd.Parameters.Add(param); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private void ConvertQualityModels(IDbConnection conn, IDbTransaction tran) - { - // Converts the QualityModel JSON objects to their new format (only storing the QualityId instead of the entire object) - ConvertQualityModel(conn, tran, "Blacklist"); - ConvertQualityModel(conn, tran, "EpisodeFiles"); - ConvertQualityModel(conn, tran, "History"); - } - - private void ConvertQualityModel(IDbConnection conn, IDbTransaction tran, string tableName) - { - var qualityModelConverter = new EmbeddedDocumentConverter(new QualityIntConverter()); - - using (IDbCommand qualityModelCmd = conn.CreateCommand()) - { - qualityModelCmd.Transaction = tran; - qualityModelCmd.CommandText = @"SELECT Distinct Quality FROM " + tableName; - using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader()) - { - while (qualityModelReader.Read()) - { - var qualityJson = qualityModelReader.GetString(0); - - SourceQualityModel036 sourceQuality; - - if (!Json.TryDeserialize(qualityJson, out sourceQuality)) - { - continue; - } - - var qualityNew = new DestinationQualityModel036 - { - Quality = sourceQuality.Quality.Id, - Proper = sourceQuality.Proper - }; - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Quality = ?"; - var param = updateCmd.CreateParameter(); - qualityModelConverter.SetValue(param, qualityNew); - updateCmd.Parameters.Add(param); - updateCmd.AddParameter(qualityJson); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private class DestinationQualityModel036 - { - public int Quality { get; set; } - public bool Proper { get; set; } - } - - private class SourceQualityModel036 - { - public SourceQuality036 Quality { get; set; } - public bool Proper { get; set; } - } - - private class SourceQuality036 - { - public int Id { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs b/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs deleted file mode 100644 index 75f08ff34..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(37)] - public class add_configurable_qualities : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Allowed").FromTable("QualityProfiles"); - - Alter.Column("Items").OnTable("QualityProfiles").AsString().NotNullable(); - - Create.TableForModel("QualityDefinitions") - .WithColumn("Quality").AsInt32().Unique() - .WithColumn("Title").AsString().Unique() - .WithColumn("Weight").AsInt32().Unique() - .WithColumn("MinSize").AsInt32() - .WithColumn("MaxSize").AsInt32(); - - Execute.WithConnection(ConvertQualities); - - Delete.Table("QualitySizes"); - } - - private void ConvertQualities(IDbConnection conn, IDbTransaction tran) - { - // Convert QualitySizes to a more generic QualityDefinitions table. - using (IDbCommand qualitySizeCmd = conn.CreateCommand()) - { - qualitySizeCmd.Transaction = tran; - qualitySizeCmd.CommandText = @"SELECT QualityId, MinSize, MaxSize FROM QualitySizes"; - using (IDataReader qualitySizeReader = qualitySizeCmd.ExecuteReader()) - { - while (qualitySizeReader.Read()) - { - var qualityId = qualitySizeReader.GetInt32(0); - var minSize = qualitySizeReader.GetInt32(1); - var maxSize = qualitySizeReader.GetInt32(2); - - var defaultConfig = Quality.DefaultQualityDefinitions.Single(p => (int)p.Quality == qualityId); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "INSERT INTO QualityDefinitions (Quality, Title, Weight, MinSize, MaxSize) VALUES (?, ?, ?, ?, ?)"; - updateCmd.AddParameter(qualityId); - updateCmd.AddParameter(defaultConfig.Title); - updateCmd.AddParameter(defaultConfig.Weight); - updateCmd.AddParameter(minSize); - updateCmd.AddParameter(maxSize); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs b/src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs deleted file mode 100644 index f5cae2ba0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/038_add_on_upgrade_to_notifications.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(38)] - public class add_on_upgrade_to_notifications : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Notifications").AddColumn("OnUpgrade").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Notifications SET OnUpgrade = OnDownload"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs b/src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs deleted file mode 100644 index fdc7f2545..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/039_add_metadata_tables.cs +++ /dev/null @@ -1,28 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(39)] - public class add_metadata_tables : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Metadata") - .WithColumn("Enable").AsBoolean().NotNullable() - .WithColumn("Name").AsString().NotNullable() - .WithColumn("Implementation").AsString().NotNullable() - .WithColumn("Settings").AsString().NotNullable() - .WithColumn("ConfigContract").AsString().NotNullable(); - - Create.TableForModel("MetadataFiles") - .WithColumn("SeriesId").AsInt32().NotNullable() - .WithColumn("Consumer").AsString().NotNullable() - .WithColumn("Type").AsInt32().NotNullable() - .WithColumn("RelativePath").AsString().NotNullable() - .WithColumn("LastUpdated").AsDateTime().NotNullable() - .WithColumn("SeasonNumber").AsInt32().Nullable() - .WithColumn("EpisodeFileId").AsInt32().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs b/src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs deleted file mode 100644 index bf8119831..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/040_add_metadata_to_episodes_and_series.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(40)] - public class add_metadata_to_episodes_and_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series") - .AddColumn("Actors").AsString().Nullable() - .AddColumn("Ratings").AsString().Nullable() - .AddColumn("Genres").AsString().Nullable() - .AddColumn("Certification").AsString().Nullable(); - - Alter.Table("Episodes") - .AddColumn("Ratings").AsString().Nullable() - .AddColumn("Images").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs b/src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs deleted file mode 100644 index 25cbc8ed4..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/041_fix_xbmc_season_images_metadata.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(41)] - public class fix_xbmc_season_images_metadata : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE MetadataFiles SET Type = 4 WHERE Consumer = 'XbmcMetadata' AND SeasonNumber IS NOT NULL"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs b/src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs deleted file mode 100644 index 08cf7622b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/042_add_download_clients_table.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(42)] - public class add_download_clients_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("DownloadClients") - .WithColumn("Enable").AsBoolean().NotNullable() - .WithColumn("Name").AsString().NotNullable() - .WithColumn("Implementation").AsString().NotNullable() - .WithColumn("Settings").AsString().NotNullable() - .WithColumn("ConfigContract").AsString().NotNullable() - .WithColumn("Protocol").AsInt32().NotNullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs b/src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs deleted file mode 100644 index 62c3fb7c3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/043_convert_config_to_download_clients.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(43)] - public class convert_config_to_download_clients : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertToThingyProvder); - } - - private void ConvertToThingyProvder(IDbConnection conn, IDbTransaction tran) - { - var config = new Dictionary(); - - using (IDbCommand configCmd = conn.CreateCommand()) - { - configCmd.Transaction = tran; - configCmd.CommandText = @"SELECT * FROM Config"; - using (IDataReader configReader = configCmd.ExecuteReader()) - { - var keyIndex = configReader.GetOrdinal("Key"); - var valueIndex = configReader.GetOrdinal("Value"); - - while (configReader.Read()) - { - var key = configReader.GetString(keyIndex); - var value = configReader.GetString(valueIndex); - - config.Add(key.ToLowerInvariant(), value); - } - } - } - - var client = GetConfigValue(config, "DownloadClient", ""); - - if (string.IsNullOrWhiteSpace(client)) - { - return; - } - - if (client.Equals("sabnzbd", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new ClientSettingsForMigration - { - Host = GetConfigValue(config, "SabHost", "localhost"), - Port = GetConfigValue(config, "SabPort", 8080), - ApiKey = GetConfigValue(config, "SabApiKey", ""), - Username = GetConfigValue(config, "SabUsername", ""), - Password = GetConfigValue(config, "SabPassword", ""), - TvCategory = GetConfigValue(config, "SabTvCategory", "tv"), - RecentTvPriority = GetSabnzbdPriority(GetConfigValue(config, "NzbgetRecentTvPriority", "Default")), - OlderTvPriority = GetSabnzbdPriority(GetConfigValue(config, "NzbgetOlderTvPriority", "Default")), - UseSsl = GetConfigValue(config, "SabUseSsl", false) - }; - - AddDownloadClient(conn, tran, "Sabnzbd", "Sabnzbd", settings.ToJson(), "SabnzbdSettings", 1); - } - else if (client.Equals("nzbget", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new ClientSettingsForMigration - { - Host = GetConfigValue(config, "NzbGetHost", "localhost"), - Port = GetConfigValue(config, "NzbgetPort", 6789), - Username = GetConfigValue(config, "NzbgetUsername", "nzbget"), - Password = GetConfigValue(config, "NzbgetPassword", ""), - TvCategory = GetConfigValue(config, "NzbgetTvCategory", "tv"), - RecentTvPriority = GetNzbgetPriority(GetConfigValue(config, "NzbgetRecentTvPriority", "Normal")), - OlderTvPriority = GetNzbgetPriority(GetConfigValue(config, "NzbgetOlderTvPriority", "Normal")), - }; - - AddDownloadClient(conn, tran, "Nzbget", "Nzbget", settings.ToJson(), "NzbgetSettings", 1); - } - else if (client.Equals("pneumatic", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new FolderSettingsForMigration - { - Folder = GetConfigValue(config, "PneumaticFolder", "") - }; - - AddDownloadClient(conn, tran, "Pneumatic", "Pneumatic", settings.ToJson(), "FolderSettings", 1); - } - else if (client.Equals("blackhole", StringComparison.InvariantCultureIgnoreCase)) - { - var settings = new FolderSettingsForMigration - { - Folder = GetConfigValue(config, "BlackholeFolder", "") - }; - - AddDownloadClient(conn, tran, "Blackhole", "Blackhole", settings.ToJson(), "FolderSettings", 1); - } - - DeleteOldConfigValues(conn, tran); - } - - private T GetConfigValue(Dictionary config, string key, T defaultValue) - { - key = key.ToLowerInvariant(); - - if (config.ContainsKey(key)) - { - return (T)Convert.ChangeType(config[key], typeof(T)); - } - - return defaultValue; - } - - private void AddDownloadClient(IDbConnection conn, - IDbTransaction tran, - string name, - string implementation, - string settings, - string configContract, - int protocol) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = string.Format("INSERT INTO DownloadClients (Enable, Name, Implementation, Settings, ConfigContract, Protocol) VALUES (1, ?, ?, ?, ?, ?)"); - updateCmd.AddParameter(name); - updateCmd.AddParameter(implementation); - updateCmd.AddParameter(settings); - updateCmd.AddParameter(configContract); - updateCmd.AddParameter(protocol); - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - - private void DeleteOldConfigValues(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - var text = "DELETE FROM Config WHERE [KEY] IN ('nzbgetusername', 'nzbgetpassword', 'nzbgethost', 'nzbgetport', " + - "'nzbgettvcategory', 'nzbgetrecenttvpriority', 'nzbgetoldertvpriority', 'sabhost', 'sabport', " + - "'sabapikey', 'sabusername', 'sabpassword', 'sabtvcategory', 'sabrecenttvpriority', " + - "'saboldertvpriority', 'sabusessl', 'downloadclient', 'blackholefolder', 'pneumaticfolder')"; - - updateCmd.Transaction = tran; - updateCmd.CommandText = text; - updateCmd.ExecuteNonQuery(); - } - } - - private int GetSabnzbdPriority(string priority) - { - return (int)Enum.Parse(typeof(SabnzbdPriorityForMigration), priority, true); - } - - private int GetNzbgetPriority(string priority) - { - return (int)Enum.Parse(typeof(NzbGetPriorityForMigration), priority, true); - } - - private class ClientSettingsForMigration - { - public string Host { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } - - private class FolderSettingsForMigration - { - public string Folder { get; set; } - } - - private enum SabnzbdPriorityForMigration - { - Default = -100, - Paused = -2, - Low = -1, - Normal = 0, - High = 1, - Force = 2 - } - - private enum NzbGetPriorityForMigration - { - VeryLow = -100, - Low = -50, - Normal = 0, - High = 50, - VeryHigh = 100 - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs b/src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs deleted file mode 100644 index 0c645259b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/044_fix_xbmc_episode_metadata.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(44)] - public class fix_xbmc_episode_metadata : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - //Convert Episode Metadata to proper type - Execute.Sql("UPDATE MetadataFiles " + - "SET Type = 2 " + - "WHERE Consumer = 'XbmcMetadata' " + - "AND EpisodeFileId IS NOT NULL " + - "AND Type = 4 " + - "AND RelativePath LIKE '%.nfo'"); - - //Convert Episode Images to proper type - Execute.Sql("UPDATE MetadataFiles " + - "SET Type = 5 " + - "WHERE Consumer = 'XbmcMetadata' " + - "AND EpisodeFileId IS NOT NULL " + - "AND Type = 4"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs b/src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs deleted file mode 100644 index c37a9fc37..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/045_add_indexes.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(45)] - public class add_indexes : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Index().OnTable("Blacklist").OnColumn("SeriesId"); - - Create.Index().OnTable("EpisodeFiles").OnColumn("SeriesId"); - - Create.Index().OnTable("Episodes").OnColumn("EpisodeFileId"); - Create.Index().OnTable("Episodes").OnColumn("SeriesId"); - - Create.Index().OnTable("History").OnColumn("EpisodeId"); - Create.Index().OnTable("History").OnColumn("Date"); - - Create.Index().OnTable("Series").OnColumn("Path"); - Create.Index().OnTable("Series").OnColumn("CleanTitle"); - Create.Index().OnTable("Series").OnColumn("TvRageId"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs b/src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs deleted file mode 100644 index 6d5496c0a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/046_fix_nzb_su_url.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(46)] - public class fix_nzb_su_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET Settings = replace(Settings, '//nzb.su', '//api.nzb.su')" + - "WHERE Implementation = 'Newznab'" + - "AND Settings LIKE '%//nzb.su%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs b/src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs deleted file mode 100644 index a7bbc9b9b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/047_add_published_date_blacklist_column.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(47)] - public class add_temporary_blacklist_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Blacklist").AddColumn("PublishedDate").AsDateTime().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs b/src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs deleted file mode 100644 index af5c7359c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/048_add_title_to_scenemappings.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(48)] - public class add_title_to_scenemappings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("SceneMappings").AddColumn("Title").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs b/src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs deleted file mode 100644 index ebbe8d8c0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/049_fix_dognzb_url.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(49)] - public class fix_dognzb_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET Settings = replace(Settings, '//dognzb.cr', '//api.dognzb.cr')" + - "WHERE Implementation = 'Newznab'" + - "AND Settings LIKE '%//dognzb.cr%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs b/src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs deleted file mode 100644 index 7f97ec993..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/050_add_hash_to_metadata_files.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(50)] - public class add_hash_to_metadata_files : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("MetadataFiles").AddColumn("Hash").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs b/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs deleted file mode 100644 index 2c314bd73..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/051_download_client_import.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Linq; -using FluentMigrator; -using Newtonsoft.Json; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(51)] - public class download_client_import : NzbDroneMigrationBase - { - 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()) - { - downloadClientsCmd.Transaction = tran; - downloadClientsCmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'downloadedepisodesfolder'"; - var downloadedEpisodesFolder = downloadClientsCmd.ExecuteScalar() as string; - - downloadClientsCmd.Transaction = tran; - downloadClientsCmd.CommandText = @"SELECT Id, Implementation, Settings, ConfigContract FROM DownloadClients WHERE ConfigContract = 'FolderSettings'"; - using (IDataReader downloadClientReader = downloadClientsCmd.ExecuteReader()) - { - while (downloadClientReader.Read()) - { - var id = downloadClientReader.GetInt32(0); - var implementation = downloadClientReader.GetString(1); - var settings = downloadClientReader.GetString(2); - var configContract = downloadClientReader.GetString(3); - - var settingsJson = JsonConvert.DeserializeObject(settings) as Newtonsoft.Json.Linq.JObject; - - if (implementation == "Blackhole") - { - var newSettings = new - { - NzbFolder = settingsJson.Value("folder"), - WatchFolder = downloadedEpisodesFolder - }.ToJson(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Implementation = ?, Settings = ?, ConfigContract = ? WHERE Id = ?"; - updateCmd.AddParameter("UsenetBlackhole"); - updateCmd.AddParameter(newSettings); - updateCmd.AddParameter("UsenetBlackholeSettings"); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - else if (implementation == "Pneumatic") - { - var newSettings = new - { - NzbFolder = settingsJson.Value("folder") - }.ToJson(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Settings = ?, ConfigContract = ? WHERE Id = ?"; - updateCmd.AddParameter(newSettings); - updateCmd.AddParameter("PneumaticSettings"); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - else - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "DELETE FROM DownloadClients WHERE Id = ?"; - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - private sealed class MigrationHistoryItem - { - public int Id { get; set; } - public int EpisodeId { get; set; } - public int SeriesId { get; set; } - public string SourceTitle { get; set; } - public DateTime Date { get; set; } - public Dictionary Data { get; set; } - public MigrationHistoryEventType EventType { get; set; } - } - - private enum MigrationHistoryEventType - { - Unknown = 0, - Grabbed = 1, - SeriesFolderImported = 2, - DownloadFolderImported = 3, - DownloadFailed = 4 - } - - private void AssociateImportedHistoryItems(IDbConnection conn, IDbTransaction tran) - { - var historyItems = new List(); - - using (IDbCommand historyCmd = conn.CreateCommand()) - { - historyCmd.Transaction = tran; - historyCmd.CommandText = @"SELECT Id, EpisodeId, SeriesId, SourceTitle, Date, Data, EventType FROM History WHERE EventType NOT NULL"; - using (IDataReader historyRead = historyCmd.ExecuteReader()) - { - while (historyRead.Read()) - { - historyItems.Add(new MigrationHistoryItem - { - Id = historyRead.GetInt32(0), - EpisodeId = historyRead.GetInt32(1), - SeriesId = historyRead.GetInt32(2), - SourceTitle = historyRead.GetString(3), - Date = historyRead.GetDateTime(4), - Data = Json.Deserialize>(historyRead.GetString(5)), - EventType = (MigrationHistoryEventType)historyRead.GetInt32(6) - }); - } - } - } - - var numHistoryItemsNotAssociated = historyItems.Count(v => v.EventType == MigrationHistoryEventType.DownloadFolderImported && - v.Data.GetValueOrDefault("downloadClientId") == null); - - if (numHistoryItemsNotAssociated == 0) - { - return; - } - - var historyItemsToAssociate = new Dictionary(); - - var historyItemsLookup = historyItems.ToLookup(v => v.EpisodeId); - - foreach (var historyItemGroup in historyItemsLookup) - { - var list = historyItemGroup.ToList(); - - for (int i = 0; i < list.Count - 1; i++) - { - var grabbedEvent = list[i]; - if (grabbedEvent.EventType != MigrationHistoryEventType.Grabbed) - { - continue; - } - - if (grabbedEvent.Data.GetValueOrDefault("downloadClient") == null || grabbedEvent.Data.GetValueOrDefault("downloadClientId") == null) - { - continue; - } - - // Check if it is already associated with a failed/imported event. - int j; - for (j = i + 1; j < list.Count; j++) - { - if (list[j].EventType != MigrationHistoryEventType.DownloadFolderImported && - list[j].EventType != MigrationHistoryEventType.DownloadFailed) - { - continue; - } - - if (list[j].Data.ContainsKey("downloadClient") && list[j].Data["downloadClient"] == grabbedEvent.Data["downloadClient"] && - list[j].Data.ContainsKey("downloadClientId") && list[j].Data["downloadClientId"] == grabbedEvent.Data["downloadClientId"]) - { - break; - } - } - - if (j != list.Count) - { - list.RemoveAt(j); - list.RemoveAt(i--); - continue; - } - - var importedEvent = list[i + 1]; - if (importedEvent.EventType != MigrationHistoryEventType.DownloadFolderImported) - { - continue; - } - - var droppedPath = importedEvent.Data.GetValueOrDefault("droppedPath"); - if (droppedPath != null && new FileInfo(droppedPath).Directory.Name == grabbedEvent.SourceTitle) - { - historyItemsToAssociate[importedEvent] = grabbedEvent; - - list.RemoveAt(i + 1); - list.RemoveAt(i--); - } - } - } - - foreach (var pair in historyItemsToAssociate) - { - using (IDbCommand updateHistoryCmd = conn.CreateCommand()) - { - pair.Key.Data["downloadClient"] = pair.Value.Data["downloadClient"]; - pair.Key.Data["downloadClientId"] = pair.Value.Data["downloadClientId"]; - - updateHistoryCmd.Transaction = tran; - updateHistoryCmd.CommandText = "UPDATE History SET Data = ? WHERE Id = ?"; - updateHistoryCmd.AddParameter(pair.Key.Data.ToJson()); - updateHistoryCmd.AddParameter(pair.Key.Id); - - updateHistoryCmd.ExecuteNonQuery(); - } - } - - _logger.Info("Updated old History items. {0}/{1} old ImportedEvents were associated with GrabbedEvents.", historyItemsToAssociate.Count, numHistoryItemsNotAssociated); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs b/src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs deleted file mode 100644 index e0dba2496..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/052_add_columns_for_anime.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(52)] - public class add_columns_for_anime : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - //Support XEM names - Alter.Table("SceneMappings").AddColumn("Type").AsString().Nullable(); - Execute.Sql("DELETE FROM SceneMappings"); - - //Add AnimeEpisodeFormat (set to Stardard Episode format for now) - Alter.Table("NamingConfig").AddColumn("AnimeEpisodeFormat").AsString().Nullable(); - Execute.Sql("UPDATE NamingConfig SET AnimeEpisodeFormat = StandardEpisodeFormat"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs b/src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs deleted file mode 100644 index 46e1b8ce3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/053_add_series_sorttitle.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(53)] - public class add_series_sorttitle : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Column("SortTitle").OnTable("Series").AsString().Nullable(); - - Execute.WithConnection(SetSortTitles); - } - - private void SetSortTitles(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = @"SELECT Id, Title FROM Series"; - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var id = seriesReader.GetInt32(0); - var title = seriesReader.GetString(1); - - var sortTitle = Parser.Parser.NormalizeTitle(title).ToLower(); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Series SET SortTitle = ? WHERE Id = ?"; - updateCmd.AddParameter(sortTitle); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs deleted file mode 100644 index 5535a1bd9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/054_rename_profiles.cs +++ /dev/null @@ -1,32 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(54)] - public class rename_profiles : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Rename.Table("QualityProfiles").To("Profiles"); - - Alter.Table("Profiles").AddColumn("Language").AsInt32().Nullable(); - Alter.Table("Profiles").AddColumn("GrabDelay").AsInt32().Nullable(); - Alter.Table("Profiles").AddColumn("GrabDelayMode").AsInt32().Nullable(); - Execute.Sql("UPDATE Profiles SET Language = 1, GrabDelay = 0, GrabDelayMode = 0"); - - //Rename QualityProfileId in Series - Alter.Table("Series").AddColumn("ProfileId").AsInt32().Nullable(); - Execute.Sql("UPDATE Series SET ProfileId = QualityProfileId"); - - //Add HeldReleases - Create.TableForModel("PendingReleases") - .WithColumn("SeriesId").AsInt32().WithDefaultValue(0) - .WithColumn("Title").AsString() - .WithColumn("Added").AsDateTime() - .WithColumn("ParsedEpisodeInfo").AsString() - .WithColumn("Release").AsString() - .WithColumn("MovieId").AsInt32().WithDefaultValue(0); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs b/src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs deleted file mode 100644 index 3f13f5e84..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/055_drop_old_profile_columns.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(55)] - public class drop_old_profile_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("QualityProfileId").FromTable("Series"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs b/src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs deleted file mode 100644 index 42ad68493..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/056_add_mediainfo_to_episodefile.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(56)] - public class add_mediainfo_to_episodefile : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("EpisodeFiles").AddColumn("MediaInfo").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs b/src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs deleted file mode 100644 index 7fcd9c31d..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/057_convert_episode_file_path_to_relative.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Data; -using System.IO; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(57)] - public class convert_episode_file_path_to_relative : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Column("RelativePath").OnTable("EpisodeFiles").AsString().Nullable(); - - //TODO: Add unique contraint for series ID and Relative Path - //TODO: Warn if multiple series share the same path - Execute.WithConnection(UpdateRelativePaths); - } - - private void UpdateRelativePaths(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = @"SELECT Id, Path FROM Series"; - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var seriesId = seriesReader.GetInt32(0); - var seriesPath = seriesReader.GetString(1) + Path.DirectorySeparatorChar; - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE EpisodeFiles SET RelativePath = REPLACE(Path, ?, '') WHERE SeriesId = ?"; - updateCmd.AddParameter(seriesPath); - updateCmd.AddParameter(seriesId); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs b/src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs deleted file mode 100644 index d2bfbcfd9..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/058_drop_epsiode_file_path.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(58)] - public class drop_episode_file_path : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Path").FromTable("EpisodeFiles"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs b/src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs deleted file mode 100644 index 0905578c5..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/059_add_enable_options_to_indexers.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(59)] - public class add_enable_options_to_indexers : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Indexers") - .AddColumn("EnableRss").AsBoolean().Nullable() - .AddColumn("EnableSearch").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Indexers SET EnableRss = Enable, EnableSearch = Enable"); - Execute.Sql("UPDATE Indexers SET EnableSearch = 0 WHERE Implementation = 'Wombles'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs b/src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs deleted file mode 100644 index 05376c1d2..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/060_remove_enable_from_indexers.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(60)] - public class remove_enable_from_indexers : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Enable").FromTable("Indexers"); - Delete.Column("Protocol").FromTable("DownloadClients"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs b/src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs deleted file mode 100644 index 4bc2275dc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/061_clear_bad_scene_names.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(61)] - public class clear_bad_scene_names : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE [EpisodeFiles] " + - "SET ReleaseGroup = NULL , SceneName = NULL " + - "WHERE " + - " ReleaseGroup IS NULL " + - " OR SceneName IS NULL " + - " OR ReleaseGroup =='DRONE' " + - " OR LENGTH(SceneName) <10 " + - " OR LENGTH(ReleaseGroup) > 20 " + - " OR SceneName NOT LIKE '%.%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs b/src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs deleted file mode 100644 index 0087345db..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/062_convert_quality_models.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; -using NzbDrone.Core.Qualities; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(62)] - public class convert_quality_models : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertQualityModels); - } - - private void ConvertQualityModels(IDbConnection conn, IDbTransaction tran) - { - ConvertQualityModelsOnTable(conn, tran, "EpisodeFiles"); - ConvertQualityModelsOnTable(conn, tran, "Blacklist"); - ConvertQualityModelsOnTable(conn, tran, "History"); - } - - private void ConvertQualityModelsOnTable(IDbConnection conn, IDbTransaction tran, string tableName) - { - var qualitiesToUpdate = new Dictionary(); - - using (IDbCommand qualityModelCmd = conn.CreateCommand()) - { - qualityModelCmd.Transaction = tran; - qualityModelCmd.CommandText = @"SELECT Distinct Quality FROM " + tableName; - - using (IDataReader qualityModelReader = qualityModelCmd.ExecuteReader()) - { - while (qualityModelReader.Read()) - { - var qualityJson = qualityModelReader.GetString(0); - - LegacyQualityModel062 quality; - - if (!Json.TryDeserialize(qualityJson, out quality)) - { - continue; - } - - var newQualityModel = new QualityModel062 { Quality = quality.Quality, Revision = new Revision() }; - if (quality.Proper) - { - newQualityModel.Revision.Version = 2; - } - - var newQualityJson = newQualityModel.ToJson(); - - qualitiesToUpdate.Add(qualityJson, newQualityJson); - } - } - } - - foreach (var quality in qualitiesToUpdate) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE " + tableName + " SET Quality = ? WHERE Quality = ?"; - updateCmd.AddParameter(quality.Value); - updateCmd.AddParameter(quality.Key); - - updateCmd.ExecuteNonQuery(); - } - } - } - - private class LegacyQualityModel062 - { - public int Quality { get; set; } - public bool Proper { get; set; } - } - - private class QualityModel062 - { - public int Quality { get; set; } - public Revision Revision { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs b/src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs deleted file mode 100644 index 2f8c6b755..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/063_add_remotepathmappings.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(63)] - public class add_remotepathmappings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("RemotePathMappings") - .WithColumn("Host").AsString() - .WithColumn("RemotePath").AsString() - .WithColumn("LocalPath").AsString(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs b/src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs deleted file mode 100644 index 2fd04ea97..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/064_add_remove_method_from_logs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(64)] - public class remove_method_from_logs : NzbDroneMigrationBase - { - protected override void LogDbUpgrade() - { - Delete.Column("Method").FromTable("Logs"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs b/src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs deleted file mode 100644 index 7936f04dd..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/065_make_scene_numbering_nullable.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(65)] - public class make_scene_numbering_nullable : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Episodes SET AbsoluteEpisodeNumber = NULL WHERE AbsoluteEpisodeNumber = 0"); - Execute.Sql("UPDATE Episodes SET SceneAbsoluteEpisodeNumber = NULL WHERE SceneAbsoluteEpisodeNumber = 0"); - Execute.Sql("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL WHERE SceneSeasonNumber = 0 AND SceneEpisodeNumber = 0"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs b/src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs deleted file mode 100644 index 7a0c09838..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/066_add_tags.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(66)] - public class add_tags : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Tags") - .WithColumn("Label").AsString().NotNullable(); - - Alter.Table("Series") - .AddColumn("Tags").AsString().Nullable(); - - Alter.Table("Notifications") - .AddColumn("Tags").AsString().Nullable(); - - Execute.Sql("UPDATE Series SET Tags = '[]'"); - Execute.Sql("UPDATE Notifications SET Tags = '[]'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs b/src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs deleted file mode 100644 index cb0923e18..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/067_add_added_to_series.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(67)] - public class add_added_to_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("Added").AsDateTime().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs b/src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs deleted file mode 100644 index a7cc93e0c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/068_add_release_restrictions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(68)] - public class add_release_restrictions : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Restrictions") - .WithColumn("Required").AsString().Nullable() - .WithColumn("Preferred").AsString().Nullable() - .WithColumn("Ignored").AsString().Nullable() - .WithColumn("Tags").AsString().NotNullable(); - - Execute.WithConnection(ConvertRestrictions); - Execute.Sql("DELETE FROM Config WHERE [Key] = 'releaserestrictions'"); - } - - private void ConvertRestrictions(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getRestictionsCmd = conn.CreateCommand()) - { - getRestictionsCmd.Transaction = tran; - getRestictionsCmd.CommandText = @"SELECT [Value] FROM Config WHERE [Key] = 'releaserestrictions'"; - - using (IDataReader configReader = getRestictionsCmd.ExecuteReader()) - { - while (configReader.Read()) - { - var restrictions = configReader.GetString(0); - restrictions = restrictions.Replace("\n", ","); - - using (IDbCommand insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = "INSERT INTO Restrictions (Ignored, Tags) VALUES (?, '[]')"; - insertCmd.AddParameter(restrictions); - - insertCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs b/src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs deleted file mode 100644 index 6185e0fd1..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/069_quality_proper.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Data; -using System.Linq; -using System.Text.RegularExpressions; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(69)] - public class quality_proper : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertQualityTitle); - } - - private static readonly Regex QualityTitleRegex = new Regex(@"\{(?[- ._\[(]*)(?(?:quality)(?:(?[- ._]+)(?:title))?)(?[- ._)\]]*)\}", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - - private void ConvertQualityTitle(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand namingConfigCmd = conn.CreateCommand()) - { - namingConfigCmd.Transaction = tran; - namingConfigCmd.CommandText = @"SELECT StandardEpisodeFormat, DailyEpisodeFormat, AnimeEpisodeFormat FROM NamingConfig LIMIT 1"; - - using (IDataReader configReader = namingConfigCmd.ExecuteReader()) - { - while (configReader.Read()) - { - var currentStandard = configReader.GetString(0); - var currentDaily = configReader.GetString(1); - var currentAnime = configReader.GetString(2); - - var newStandard = GetNewFormat(currentStandard); - var newDaily = GetNewFormat(currentDaily); - var newAnime = GetNewFormat(currentAnime); - - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - - updateCmd.CommandText = "UPDATE NamingConfig SET StandardEpisodeFormat = ?, DailyEpisodeFormat = ?, AnimeEpisodeFormat = ?"; - updateCmd.AddParameter(newStandard); - updateCmd.AddParameter(newDaily); - updateCmd.AddParameter(newAnime); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - - private string GetNewFormat(string currentFormat) - { - var matches = QualityTitleRegex.Matches(currentFormat); - var result = currentFormat; - - foreach (Match match in matches) - { - var tokenMatch = GetTokenMatch(match); - var qualityFullToken = string.Format("Quality{0}Full", tokenMatch.Separator); - - if (tokenMatch.Token.All(t => !char.IsLetter(t) || char.IsLower(t))) - { - qualityFullToken = string.Format("quality{0}full", tokenMatch.Separator); - } - else if (tokenMatch.Token.All(t => !char.IsLetter(t) || char.IsUpper(t))) - { - qualityFullToken = string.Format("QUALITY{0}FULL", tokenMatch.Separator); - } - - result = result.Replace(match.Groups["token"].Value, qualityFullToken); - } - - return result; - } - - private TokenMatch69 GetTokenMatch(Match match) - { - return new TokenMatch69 - { - Prefix = match.Groups["prefix"].Value, - Token = match.Groups["token"].Value, - Separator = match.Groups["separator"].Value, - Suffix = match.Groups["suffix"].Value, - }; - } - - private class TokenMatch69 - { - public string Prefix { get; set; } - public string Token { get; set; } - public string Separator { get; set; } - public string Suffix { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs b/src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs deleted file mode 100644 index e77f5f9f7..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/070_delay_profile.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(70)] - public class delay_profile : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("DelayProfiles") - .WithColumn("EnableUsenet").AsBoolean().NotNullable() - .WithColumn("EnableTorrent").AsBoolean().NotNullable() - .WithColumn("PreferredProtocol").AsInt32().NotNullable() - .WithColumn("UsenetDelay").AsInt32().NotNullable() - .WithColumn("TorrentDelay").AsInt32().NotNullable() - .WithColumn("Order").AsInt32().NotNullable() - .WithColumn("Tags").AsString().NotNullable(); - - Insert.IntoTable("DelayProfiles").Row(new - { - EnableUsenet = 1, - EnableTorrent = 1, - PreferredProtocol = 1, - UsenetDelay = 0, - TorrentDelay = 0, - Order = int.MaxValue, - Tags = "[]" - }); - - Execute.WithConnection(ConvertProfile); - - Delete.Column("GrabDelay").FromTable("Profiles"); - Delete.Column("GrabDelayMode").FromTable("Profiles"); - } - - private void ConvertProfile(IDbConnection conn, IDbTransaction tran) - { - var profiles = GetProfiles(conn, tran); - var order = 1; - - foreach (var profileClosure in profiles.DistinctBy(p => p.GrabDelay)) - { - var profile = profileClosure; - if (profile.GrabDelay == 0) - { - continue; - } - - var tag = string.Format("delay-{0}", profile.GrabDelay); - var tagId = InsertTag(conn, tran, tag); - var tags = string.Format("[{0}]", tagId); - - using (IDbCommand insertDelayProfileCmd = conn.CreateCommand()) - { - insertDelayProfileCmd.Transaction = tran; - insertDelayProfileCmd.CommandText = "INSERT INTO DelayProfiles (EnableUsenet, EnableTorrent, PreferredProtocol, TorrentDelay, UsenetDelay, [Order], Tags) VALUES (1, 1, 1, 0, ?, ?, ?)"; - insertDelayProfileCmd.AddParameter(profile.GrabDelay); - insertDelayProfileCmd.AddParameter(order); - insertDelayProfileCmd.AddParameter(tags); - - insertDelayProfileCmd.ExecuteNonQuery(); - } - - var matchingProfileIds = profiles.Where(p => p.GrabDelay == profile.GrabDelay) - .Select(p => p.Id); - - UpdateSeries(conn, tran, matchingProfileIds, tagId); - - order++; - } - } - - private List GetProfiles(IDbConnection conn, IDbTransaction tran) - { - var profiles = new List(); - - using (IDbCommand getProfilesCmd = conn.CreateCommand()) - { - getProfilesCmd.Transaction = tran; - getProfilesCmd.CommandText = @"SELECT Id, GrabDelay FROM Profiles"; - - using (IDataReader profileReader = getProfilesCmd.ExecuteReader()) - { - while (profileReader.Read()) - { - var id = profileReader.GetInt32(0); - var delay = profileReader.GetInt32(1); - - profiles.Add(new Profile69 - { - Id = id, - GrabDelay = delay * 60 - }); - } - } - } - - return profiles; - } - - private int InsertTag(IDbConnection conn, IDbTransaction tran, string tagLabel) - { - using (IDbCommand insertCmd = conn.CreateCommand()) - { - insertCmd.Transaction = tran; - insertCmd.CommandText = @"INSERT INTO Tags (Label) VALUES (?); SELECT last_insert_rowid()"; - insertCmd.AddParameter(tagLabel); - - var id = insertCmd.ExecuteScalar(); - - return Convert.ToInt32(id); - } - } - - private void UpdateSeries(IDbConnection conn, IDbTransaction tran, IEnumerable profileIds, int tagId) - { - using (IDbCommand getSeriesCmd = conn.CreateCommand()) - { - getSeriesCmd.Transaction = tran; - getSeriesCmd.CommandText = "SELECT Id, Tags FROM Series WHERE ProfileId IN (?)"; - getSeriesCmd.AddParameter(string.Join(",", profileIds)); - - using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) - { - while (seriesReader.Read()) - { - var id = seriesReader.GetInt32(0); - var tagString = seriesReader.GetString(1); - - var tags = Json.Deserialize>(tagString); - tags.Add(tagId); - - using (IDbCommand updateSeriesCmd = conn.CreateCommand()) - { - updateSeriesCmd.Transaction = tran; - updateSeriesCmd.CommandText = "UPDATE Series SET Tags = ? WHERE Id = ?"; - updateSeriesCmd.AddParameter(tags.ToJson()); - updateSeriesCmd.AddParameter(id); - - updateSeriesCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class Profile69 - { - public int Id { get; set; } - public int GrabDelay { get; set; } - } - - public class Series69 - { - public int Id { get; set; } - public List Tags { get; set; } - public DateTime? LastInfoSync { get; set; } - } - - public class Tag69 - { - public int Id { get; set; } - public string Label { get; set; } - } - - public class DelayProfile70 - { - public int Id { get; set; } - public bool EnableUsenet { get; set; } - public bool EnableTorrent { get; set; } - public int PreferredProtocol { get; set; } - public int UsenetDelay { get; set; } - public int TorrentDelay { get; set; } - public int Order { get; set; } - public List Tags { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs b/src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs deleted file mode 100644 index ab500282b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/071_unknown_quality_in_profile.cs +++ /dev/null @@ -1,238 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(71)] - public class unknown_quality_in_profile : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.Column("Weight").FromTable("QualityDefinitions"); - - Execute.WithConnection(ConvertProfile); - } - - private void ConvertProfile(IDbConnection conn, IDbTransaction tran) - { - var updater = new ProfileUpdater70(conn, tran); - updater.PrependQuality(0); - updater.Commit(); - } - } - - public class Profile70 - { - public int Id { get; set; } - public string Name { get; set; } - public int Cutoff { get; set; } - public List Items { get; set; } - public int Language { get; set; } - public List PreferredTags { get; set; } - } - - public class ProfileItem70 - { - public int? QualityDefinition { get; set; } - public int? Quality { get; set; } - public bool Allowed { get; set; } - } - - public class QualityDefinition70 - { - public int Id { get; set; } - public int Quality { get; set; } - } - - public class ProfileUpdater70 - { - private readonly IDbConnection _connection; - private readonly IDbTransaction _transaction; - - private List _profiles; - private HashSet _changedProfiles = new HashSet(); - - public ProfileUpdater70(IDbConnection conn, IDbTransaction tran) - { - _connection = conn; - _transaction = tran; - - _profiles = GetProfiles(); - } - - public void Commit() - { - foreach (var profile in _changedProfiles) - { - using (var updateProfileCmd = _connection.CreateCommand()) - { - updateProfileCmd.Transaction = _transaction; - updateProfileCmd.CommandText = "UPDATE Profiles SET Name = ?, Cutoff = ?, Items = ?, Language = ? WHERE Id = ?"; - updateProfileCmd.AddParameter(profile.Name); - updateProfileCmd.AddParameter(profile.Cutoff); - updateProfileCmd.AddParameter(profile.Items.ToJson()); - updateProfileCmd.AddParameter(profile.Language); - updateProfileCmd.AddParameter(profile.Id); - - updateProfileCmd.ExecuteNonQuery(); - } - } - - _changedProfiles.Clear(); - } - - public void PrependQuality(int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) - { - continue; - } - - profile.Items.Insert(0, new ProfileItem70 - { - Quality = quality, - Allowed = false - }); - - _changedProfiles.Add(profile); - } - } - - public void AppendQuality(int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) - { - continue; - } - - profile.Items.Add(new ProfileItem70 - { - Quality = quality, - Allowed = false - }); - - _changedProfiles.Add(profile); - } - } - - public void SplitQualityPrepend(int find, int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) - { - continue; - } - - var findIndex = profile.Items.FindIndex(v => v.Quality == find); - - profile.Items.Insert(findIndex, new ProfileItem70 - { - Quality = quality, - Allowed = profile.Items[findIndex].Allowed - }); - - if (profile.Cutoff == find) - { - profile.Cutoff = quality; - } - - _changedProfiles.Add(profile); - } - } - - public void SplitQualityAppend(int find, int quality) - { - foreach (var profile in _profiles) - { - if (profile.Items.Any(v => v.Quality == quality)) - { - continue; - } - - var findIndex = profile.Items.FindIndex(v => v.Quality == find); - - profile.Items.Insert(findIndex + 1, new ProfileItem70 - { - Quality = quality, - Allowed = false - }); - - _changedProfiles.Add(profile); - } - } - - public void UpdateQualityToQualityDefinition() - { - var definitions = new List(); - using (var getDefinitions = _connection.CreateCommand()) - { - getDefinitions.Transaction = _transaction; - getDefinitions.CommandText = @"SELECT Id, Quality FROM QualityDefinitions"; - - using (var definitionsReader = getDefinitions.ExecuteReader()) - { - while (definitionsReader.Read()) - { - int id = definitionsReader.GetInt32(0); - int quality = definitionsReader.GetInt32(1); - definitions.Add(new QualityDefinition70 { Id = id, Quality = quality }); - } - } - } - - foreach (var profile in _profiles) - { - profile.Items = profile.Items.Select(i => - { - return new ProfileItem70 - { - Allowed = i.Allowed, - Quality = i.Quality, - QualityDefinition = definitions.Find(d => d.Quality == i.Quality).Id - }; - }).ToList(); - - profile.Cutoff = definitions.Find(d => d.Quality == profile.Cutoff).Id; - - _changedProfiles.Add(profile); - } - } - - private List GetProfiles() - { - var profiles = new List(); - - using (var getProfilesCmd = _connection.CreateCommand()) - { - getProfilesCmd.Transaction = _transaction; - getProfilesCmd.CommandText = @"SELECT Id, Name, Cutoff, Items, Language FROM Profiles"; - - using (var profileReader = getProfilesCmd.ExecuteReader()) - { - while (profileReader.Read()) - { - profiles.Add(new Profile70 - { - Id = profileReader.GetInt32(0), - Name = profileReader.GetString(1), - Cutoff = profileReader.GetInt32(2), - Items = Json.Deserialize>(profileReader.GetString(3)), - Language = profileReader.GetInt32(4) - }); - } - } - } - - return profiles; - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs b/src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs deleted file mode 100644 index 40eece1a0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/072_history_grabid.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(72)] - public class history_downloadId : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("History") - .AddColumn("DownloadId").AsString() - .Nullable() - .Indexed(); - - Execute.WithConnection(MoveToColumn); - } - - private void MoveToColumn(IDbConnection conn, IDbTransaction tran) - { - using (IDbCommand getHistory = conn.CreateCommand()) - { - getHistory.Transaction = tran; - getHistory.CommandText = @"SELECT Id, Data FROM History WHERE Data LIKE '%downloadClientId%'"; - - using (var historyReader = getHistory.ExecuteReader()) - { - while (historyReader.Read()) - { - var id = historyReader.GetInt32(0); - var data = historyReader.GetString(1); - - UpdateHistory(tran, conn, id, data); - } - } - } - } - - private void UpdateHistory(IDbTransaction tran, IDbConnection conn, int id, string data) - { - var dic = Json.Deserialize>(data); - - var downloadId = dic["downloadClientId"]; - dic.Remove("downloadClientId"); - - using (var updateHistoryCmd = conn.CreateCommand()) - { - updateHistoryCmd.Transaction = tran; - updateHistoryCmd.CommandText = @"UPDATE History SET DownloadId = ?, Data = ? WHERE Id = ?"; - - updateHistoryCmd.AddParameter(downloadId); - updateHistoryCmd.AddParameter(dic.ToJson()); - updateHistoryCmd.AddParameter(id); - - updateHistoryCmd.ExecuteNonQuery(); - } - } - } - - public class History72 - { - public int EpisodeId { get; set; } - public int SeriesId { get; set; } - public string SourceTitle { get; set; } - public string Quality { get; set; } - public DateTime Date { get; set; } - public int EventType { get; set; } - public Dictionary Data { get; set; } - - public string DownloadId { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs b/src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs deleted file mode 100644 index b1b547b60..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/073_clear_ratings.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(73)] - public class clear_ratings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("Series") - .Set(new { Ratings = "{}" }) - .AllRows(); - - Update.Table("Episodes") - .Set(new { Ratings = "{}" }) - .AllRows(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs b/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs deleted file mode 100644 index c090df19b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/074_disable_eztv.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(74)] - public class disable_eztv : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET EnableRss = 0, EnableSearch = 0 WHERE Implementation = 'Eztv' AND Settings LIKE '%ezrss.it%'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs b/src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs deleted file mode 100644 index 5a9336f64..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/075_force_lib_update.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(75)] - public class force_lib_update : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Update.Table("ScheduledTasks") - .Set(new { LastExecution = "2014-01-01 00:00:00" }) - .Where(new { TypeName = "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand" }); - - Update.Table("Series") - .Set(new { LastInfoSync = "2014-01-01 00:00:00" }) - .AllRows(); - } - } - - public class ScheduledTasks75 - { - public int Id { get; set; } - public string TypeName { get; set; } - public int Interval { get; set; } - public DateTime LastExecution { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs b/src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs deleted file mode 100644 index 7933d90d4..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/076_add_users_table.cs +++ /dev/null @@ -1,17 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(76)] - public class add_users_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Users") - .WithColumn("Identifier").AsString().NotNullable().Unique() - .WithColumn("Username").AsString().NotNullable().Unique() - .WithColumn("Password").AsString().NotNullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs b/src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs deleted file mode 100644 index 5c4891e5c..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/077_add_add_options_to_series.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(77)] - public class add_add_options_to_series : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("AddOptions").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs b/src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs deleted file mode 100644 index 5a3d93716..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/078_add_commands_table.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(78)] - public class add_commands_table : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("Commands") - .WithColumn("Name").AsString().NotNullable() - .WithColumn("Body").AsString().NotNullable() - .WithColumn("Priority").AsInt32().NotNullable() - .WithColumn("Status").AsInt32().NotNullable() - .WithColumn("QueuedAt").AsDateTime().NotNullable() - .WithColumn("StartedAt").AsDateTime().Nullable() - .WithColumn("EndedAt").AsDateTime().Nullable() - .WithColumn("Duration").AsString().Nullable() - .WithColumn("Exception").AsString().Nullable() - .WithColumn("Trigger").AsInt32().NotNullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs b/src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs deleted file mode 100644 index 6b753635a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/079_dedupe_tags.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using FluentMigrator; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(79)] - public class dedupe_tags : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(CleanupTags); - - Alter.Table("Tags").AlterColumn("Label").AsString().Unique(); - } - - private void CleanupTags(IDbConnection conn, IDbTransaction tran) - { - var tags = GetTags(conn, tran); - var grouped = tags.GroupBy(t => t.Label.ToLowerInvariant()); - var replacements = new List(); - - foreach (var group in grouped.Where(g => g.Count() > 1)) - { - var first = group.First().Id; - - foreach (var other in group.Skip(1).Select(t => t.Id)) - { - replacements.Add(new TagReplacement079 { OldId = other, NewId = first }); - } - } - - UpdateTaggedModel(conn, tran, "Series", replacements); - UpdateTaggedModel(conn, tran, "Notifications", replacements); - UpdateTaggedModel(conn, tran, "DelayProfiles", replacements); - UpdateTaggedModel(conn, tran, "Restrictions", replacements); - - DeleteTags(conn, tran, replacements); - } - - private List GetTags(IDbConnection conn, IDbTransaction tran) - { - var tags = new List(); - - using (IDbCommand tagCmd = conn.CreateCommand()) - { - tagCmd.Transaction = tran; - tagCmd.CommandText = @"SELECT Id, Label FROM Tags"; - - using (IDataReader tagReader = tagCmd.ExecuteReader()) - { - while (tagReader.Read()) - { - var id = tagReader.GetInt32(0); - var label = tagReader.GetString(1); - - tags.Add(new Tag079 { Id = id, Label = label }); - } - } - } - - return tags; - } - - private void UpdateTaggedModel(IDbConnection conn, IDbTransaction tran, string table, List replacements) - { - var tagged = new List(); - - using (IDbCommand tagCmd = conn.CreateCommand()) - { - tagCmd.Transaction = tran; - tagCmd.CommandText = string.Format("SELECT Id, Tags FROM {0}", table); - - using (IDataReader tagReader = tagCmd.ExecuteReader()) - { - while (tagReader.Read()) - { - if (!tagReader.IsDBNull(1)) - { - var id = tagReader.GetInt32(0); - var tags = tagReader.GetString(1); - - tagged.Add(new TaggedModel079 - { - Id = id, - Tags = Json.Deserialize>(tags) - }); - } - } - } - } - - var toUpdate = new List(); - - foreach (var model in tagged) - { - foreach (var replacement in replacements) - { - if (model.Tags.Contains(replacement.OldId)) - { - model.Tags.Remove(replacement.OldId); - model.Tags.Add(replacement.NewId); - - toUpdate.Add(model); - } - } - } - - foreach (var model in toUpdate.DistinctBy(m => m.Id)) - { - using (IDbCommand updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = string.Format(@"UPDATE {0} SET Tags = ? WHERE Id = ?", table); - updateCmd.AddParameter(model.Tags.ToJson()); - updateCmd.AddParameter(model.Id); - - updateCmd.ExecuteNonQuery(); - } - } - } - - private void DeleteTags(IDbConnection conn, IDbTransaction tran, List replacements) - { - var idsToRemove = replacements.Select(r => r.OldId).Distinct(); - - using (IDbCommand removeCmd = conn.CreateCommand()) - { - removeCmd.Transaction = tran; - removeCmd.CommandText = string.Format("DELETE FROM Tags WHERE Id IN ({0})", string.Join(",", idsToRemove)); - removeCmd.ExecuteNonQuery(); - } - } - - private class Tag079 - { - public int Id { get; set; } - public string Label { get; set; } - } - - private class TagReplacement079 - { - public int OldId { get; set; } - public int NewId { get; set; } - } - - private class TaggedModel079 - { - public int Id { get; set; } - public HashSet Tags { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs b/src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs deleted file mode 100644 index c48fd75a8..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/081_move_dot_prefix_to_transmission_category.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(81)] - public class move_dot_prefix_to_transmission_category : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM DownloadClients WHERE Implementation = 'Transmission'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - - var settings = Json.Deserialize>(settingsJson); - - var tvCategory = settings.GetValueOrDefault("tvCategory") as string; - if (tvCategory.IsNotNullOrWhiteSpace()) - { - settings["tvCategory"] = "." + tvCategory; - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } - - public class DownloadClientDefinition81 - { - public int Id { get; set; } - public bool Enable { get; set; } - public string Name { get; set; } - public string Implementation { get; set; } - public JObject Settings { get; set; } - public string ConfigContract { get; set; } - } - - public class SabnzbdSettings81 - { - public string Host { get; set; } - public int Port { get; set; } - public string ApiKey { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } - - public class TransmissionSettings81 - { - public string Host { get; set; } - public int Port { get; set; } - public string UrlBase { get; set; } - public string Username { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public string TvDirectory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs b/src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs deleted file mode 100644 index 43d332224..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/082_add_fanzub_settings.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(82)] - public class add_fanzub_settings : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET ConfigContract = 'FanzubSettings' WHERE Implementation = 'Fanzub' AND ConfigContract = 'NullConfig'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs b/src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs deleted file mode 100644 index 93fa2fd51..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/083_additonal_blacklist_columns.cs +++ /dev/null @@ -1,22 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(83)] - public class additonal_blacklist_columns : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Blacklist").AddColumn("Size").AsInt64().Nullable(); - Alter.Table("Blacklist").AddColumn("Protocol").AsInt32().Nullable(); - Alter.Table("Blacklist").AddColumn("Indexer").AsString().Nullable(); - Alter.Table("Blacklist").AddColumn("Message").AsString().Nullable(); - Alter.Table("Blacklist").AddColumn("TorrentInfoHash").AsString().Nullable(); - - Update.Table("Blacklist") - .Set(new { Protocol = 1 }) - .AllRows(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs b/src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs deleted file mode 100644 index 03a0a8ea3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/084_update_quality_minmax_size.cs +++ /dev/null @@ -1,26 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(84)] - public class update_quality_minmax_size : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("QualityDefinitions").AlterColumn("MinSize").AsDouble().Nullable(); - Alter.Table("QualityDefinitions").AlterColumn("MaxSize").AsDouble().Nullable(); - - Execute.Sql("UPDATE QualityDefinitions SET MaxSize = NULL WHERE Quality = 10 OR MaxSize = 0"); - } - } - - public class QualityDefinition84 - { - public int Id { get; set; } - public int Quality { get; set; } - public string Title { get; set; } - public int? MinSize { get; set; } - public int? MaxSize { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs b/src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs deleted file mode 100644 index 8ef73a2e4..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/085_expand_transmission_urlbase.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - // this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3 -#pragma warning disable SA1200 - using NzbDrone.Common.Extensions; -#pragma warning restore SA1200 - - [Migration(85)] - public class expand_transmission_urlbase : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM DownloadClients WHERE Implementation = 'Transmission'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - - var settings = Json.Deserialize>(settingsJson); - - var urlBase = settings.GetValueOrDefault("urlBase", "") as string; - - if (urlBase.IsNullOrWhiteSpace()) - { - settings["urlBase"] = "/transmission/"; - } - else - { - settings["urlBase"] = string.Format("/{0}/transmission/", urlBase.Trim('/')); - } - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE DownloadClients SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class DelugeSettings85 - { - public string Host { get; set; } - public int Port { get; set; } - public string UrlBase { get; set; } - public string Password { get; set; } - public string TvCategory { get; set; } - public int RecentTvPriority { get; set; } - public int OlderTvPriority { get; set; } - public bool UseSsl { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs b/src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs deleted file mode 100644 index 9d1962616..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/086_pushbullet_device_ids.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - // this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3 -#pragma warning disable SA1200 - using NzbDrone.Common.Extensions; -#pragma warning restore SA1200 - - [Migration(86)] - public class pushbullet_device_ids : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM Notifications WHERE Implementation = 'PushBullet'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - var settings = Json.Deserialize>(settingsJson); - - if (settings.ContainsKey("deviceId")) - { - var deviceId = settings.GetValueOrDefault("deviceId", "") as string; - - settings.Add("deviceIds", new[] { deviceId }); - settings.Remove("deviceId"); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Notifications SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - } - - public class Notification86 - { - public int Id { get; set; } - public string Name { get; set; } - public int OnGrab { get; set; } - public int OnDownload { get; set; } - public JObject Settings { get; set; } - public string Implementation { get; set; } - public string ConfigContract { get; set; } - public int OnUpgrade { get; set; } - public List Tags { get; set; } - } - - public class PushBulletSettings86 - { - public string ApiKey { get; set; } - public string[] DeviceIds { get; set; } - public string ChannelTags { get; set; } - public string SenderId { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs b/src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs deleted file mode 100644 index d6990053a..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/087_remove_eztv.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(87)] - public class remove_eztv : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("DELETE FROM Indexers WHERE Implementation = 'Eztv'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs b/src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs deleted file mode 100644 index cd55fb831..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/088_pushbullet_devices_channels_list.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using FluentMigrator; -using NzbDrone.Common.Serializer; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - // this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3 -#pragma warning disable SA1200 - using NzbDrone.Common.Extensions; -#pragma warning restore SA1200 - - [Migration(88)] - public class pushbullet_devices_channels_list : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(UpdateTransmissionSettings); - } - - private void UpdateTransmissionSettings(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Settings FROM Notifications WHERE Implementation = 'PushBullet'"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var settingsJson = reader.GetString(1); - var settings = Json.Deserialize>(settingsJson); - - if (settings.ContainsKey("deviceIds")) - { - var deviceIdsString = settings.GetValueOrDefault("deviceIds", "") as string; - - if (deviceIdsString.IsNotNullOrWhiteSpace()) - { - var deviceIds = deviceIdsString.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - - settings["deviceIds"] = deviceIds; - } - } - - if (settings.ContainsKey("channelTags")) - { - var channelTagsString = settings.GetValueOrDefault("channelTags", "") as string; - - if (channelTagsString.IsNotNullOrWhiteSpace()) - { - var channelTags = channelTagsString.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - - settings["channelTags"] = channelTags; - } - } - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE Notifications SET Settings = ? WHERE Id = ?"; - updateCmd.AddParameter(settings.ToJson()); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class PushBulletSettings88 - { - public string ApiKey { get; set; } - public string[] DeviceIds { get; set; } - public string[] ChannelTags { get; set; } - public string SenderId { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs b/src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs deleted file mode 100644 index e06db676b..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/089_add_on_rename_to_notifcations.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(89)] - public class add_on_rename_to_notifcations : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Notifications").AddColumn("OnRename").AsBoolean().Nullable(); - - Execute.Sql("UPDATE Notifications SET OnRename = OnDownload WHERE Implementation IN ('PlexServer', 'Xbmc', 'MediaBrowser')"); - Execute.Sql("UPDATE Notifications SET OnRename = 0 WHERE Implementation NOT IN ('PlexServer', 'Xbmc', 'MediaBrowser')"); - - Alter.Table("Notifications").AlterColumn("OnRename").AsBoolean().NotNullable(); - - Execute.Sql("UPDATE Notifications SET OnGrab = 0 WHERE Implementation = 'PlexServer'"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs b/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs deleted file mode 100644 index bc22b3258..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/090_update_kickass_url.cs +++ /dev/null @@ -1,35 +0,0 @@ -using FluentMigrator; -using Newtonsoft.Json.Linq; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(90)] - public class update_kickass_url : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql( - "UPDATE Indexers SET Settings = Replace(Settings, 'kickass.so', 'kat.cr') WHERE Implementation = 'KickassTorrents';" + - "UPDATE Indexers SET Settings = Replace(Settings, 'kickass.to', 'kat.cr') WHERE Implementation = 'KickassTorrents';" + - "UPDATE Indexers SET Settings = Replace(Settings, 'http://', 'https://') WHERE Implementation = 'KickassTorrents';"); - } - } - - public class IndexerDefinition90 - { - public int Id { get; set; } - public string Name { get; set; } - public JObject Settings { get; set; } - public string Implementation { get; set; } - public string ConfigContract { get; set; } - public bool EnableRss { get; set; } - public bool EnableSearch { get; set; } - } - - public class KickassTorrentsSettings90 - { - public string BaseUrl { get; set; } - public bool VerifiedOnly { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs b/src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs deleted file mode 100644 index 9a384c298..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/091_added_indexerstatus.cs +++ /dev/null @@ -1,20 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(91)] - public class added_indexerstatus : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("IndexerStatus") - .WithColumn("IndexerId").AsInt32().NotNullable().Unique() - .WithColumn("InitialFailure").AsDateTime().Nullable() - .WithColumn("MostRecentFailure").AsDateTime().Nullable() - .WithColumn("EscalationLevel").AsInt32().NotNullable() - .WithColumn("DisabledTill").AsDateTime().Nullable() - .WithColumn("LastRssSyncReleaseInfo").AsString().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs b/src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs deleted file mode 100644 index 5366b0fad..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/092_add_unverifiedscenenumbering.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(92)] - public class add_unverifiedscenenumbering : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Episodes").AddColumn("UnverifiedSceneNumbering").AsBoolean().WithDefaultValue(false); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs b/src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs deleted file mode 100644 index 4ba4be853..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/093_naming_config_replace_characters.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(93)] - public class naming_config_replace_illegal_characters : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("NamingConfig").AddColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true); - Update.Table("NamingConfig").Set(new { ReplaceIllegalCharacters = true }).AllRows(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs b/src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs deleted file mode 100644 index 007716bfc..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/094_add_tvmazeid.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(94)] - public class add_tvmazeid : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("Series").AddColumn("TvMazeId").AsInt32().WithDefaultValue(0); - Create.Index().OnTable("Series").OnColumn("TvMazeId"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs b/src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs deleted file mode 100644 index 5d7a08b62..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/095_add_additional_episodes_index.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(95)] - public class add_additional_episodes_index : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.Index().OnTable("Episodes").OnColumn("SeriesId").Ascending() - .OnColumn("SeasonNumber").Ascending() - .OnColumn("EpisodeNumber").Ascending(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs b/src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs deleted file mode 100644 index 69894cbce..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/096_disable_kickass.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(96)] - public class disable_kickass : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.Sql("UPDATE Indexers SET EnableRss = 0, EnableSearch = 0, Settings = Replace(Settings, 'https://kat.cr', '') WHERE Implementation = 'KickassTorrents' AND Settings LIKE '%kat.cr%';"); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs b/src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs deleted file mode 100644 index 86b2eba1e..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/098_remove_titans_of_tv.cs +++ /dev/null @@ -1,14 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(98)] - public class remove_titans_of_tv : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Delete.FromTable("Indexers").Row(new { Implementation = "TitansOfTv" }); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs b/src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs deleted file mode 100644 index f7a173157..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/099_extra_and_subtitle_files.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(99)] - public class extra_and_subtitle_files : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Create.TableForModel("ExtraFiles") - .WithColumn("SeriesId").AsInt32().NotNullable() - .WithColumn("SeasonNumber").AsInt32().NotNullable() - .WithColumn("EpisodeFileId").AsInt32().NotNullable() - .WithColumn("RelativePath").AsString().NotNullable() - .WithColumn("Extension").AsString().NotNullable() - .WithColumn("Added").AsDateTime().NotNullable() - .WithColumn("LastUpdated").AsDateTime().NotNullable(); - - Create.TableForModel("SubtitleFiles") - .WithColumn("SeriesId").AsInt32().NotNullable() - .WithColumn("SeasonNumber").AsInt32().NotNullable() - .WithColumn("EpisodeFileId").AsInt32().NotNullable() - .WithColumn("RelativePath").AsString().NotNullable() - .WithColumn("Extension").AsString().NotNullable() - .WithColumn("Added").AsDateTime().NotNullable() - .WithColumn("LastUpdated").AsDateTime().NotNullable() - .WithColumn("Language").AsInt32().NotNullable(); - - Alter.Table("MetadataFiles") - .AddColumn("Added").AsDateTime().Nullable() - .AddColumn("Extension").AsString().Nullable(); - - // Remove Metadata files that don't have an extension - Execute.Sql("DELETE FROM MetadataFiles WHERE RelativePath NOT LIKE '%.%'"); - - // Set Extension using the extension from RelativePath - Execute.WithConnection(SetMetadataFileExtension); - - Alter.Table("MetadataFiles").AlterColumn("Extension").AsString().NotNullable(); - } - - private void SetMetadataFileExtension(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, RelativePath FROM MetadataFiles"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var relativePath = reader.GetString(1); - var extension = relativePath.Substring(relativePath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE MetadataFiles SET Extension = ? WHERE Id = ?"; - updateCmd.AddParameter(extension); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } - - public class MetadataFile99 - { - public int Id { get; set; } - public int SeriesId { get; set; } - public int? EpisodeFileId { get; set; } - public int? SeasonNumber { get; set; } - public string RelativePath { get; set; } - public DateTime Added { get; set; } - public DateTime LastUpdated { get; set; } - public string Extension { get; set; } - public string Hash { get; set; } - public string Consumer { get; set; } - public int Type { get; set; } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs b/src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs deleted file mode 100644 index 3cd11f6f0..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/100_add_scene_season_number.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(100)] - public class add_scene_season_number : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Alter.Table("SceneMappings").AlterColumn("SeasonNumber").AsInt32().Nullable(); - Alter.Table("SceneMappings").AddColumn("SceneSeasonNumber").AsInt32().Nullable(); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs deleted file mode 100644 index 171607fa6..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/101_add_ultrahd_quality_in_profiles.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(101)] - public class add_ultrahd_quality_in_profiles : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(ConvertProfile); - } - - private void ConvertProfile(IDbConnection conn, IDbTransaction tran) - { - var updater = new ProfileUpdater70(conn, tran); - updater.AppendQuality(16); // HDTV2160p - updater.AppendQuality(18); // WEBDL2160p - updater.AppendQuality(19); // Bluray2160p - updater.Commit(); - - // WEBRip migrations. - //updater.SplitQualityAppend(1, 11); // HDTV480p after SDTV - //updater.SplitQualityPrepend(8, 12); // WEBRip480p before WEBDL480p - //updater.SplitQualityAppend(2, 13); // Bluray480p after DVD - //updater.SplitQualityPrepend(5, 14); // WEBRip720p before WEBDL720p - //updater.SplitQualityPrepend(3, 15); // WEBRip1080p before WEBDL1080p - //updater.SplitQualityPrepend(18, 17); // WEBRip2160p before WEBDL2160p - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs b/src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs deleted file mode 100644 index d4ed853a3..000000000 --- a/src/NzbDrone.Core/Datastore/Migration/103_fix_metadata_file_extensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Data; -using FluentMigrator; -using NzbDrone.Core.Datastore.Migration.Framework; - -namespace NzbDrone.Core.Datastore.Migration -{ - [Migration(103)] - public class fix_metadata_file_extensions : NzbDroneMigrationBase - { - protected override void MainDbUpgrade() - { - Execute.WithConnection(SetMetadataFileExtension); - } - - private void SetMetadataFileExtension(IDbConnection conn, IDbTransaction tran) - { - using (var cmd = conn.CreateCommand()) - { - cmd.Transaction = tran; - cmd.CommandText = "SELECT Id, Extension FROM MetadataFiles"; - - using (var reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - var id = reader.GetInt32(0); - var extension = reader.GetString(1); - extension = extension.Substring(extension.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - - using (var updateCmd = conn.CreateCommand()) - { - updateCmd.Transaction = tran; - updateCmd.CommandText = "UPDATE MetadataFiles SET Extension = ? WHERE Id = ?"; - updateCmd.AddParameter(extension); - updateCmd.AddParameter(id); - - updateCmd.ExecuteNonQuery(); - } - } - } - } - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/126_update_qualities_and_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/126_update_qualities_and_profiles.cs index efece9a27..70a3a231a 100644 --- a/src/NzbDrone.Core/Datastore/Migration/126_update_qualities_and_profiles.cs +++ b/src/NzbDrone.Core/Datastore/Migration/126_update_qualities_and_profiles.cs @@ -1,5 +1,8 @@ -using System.Data; +using System.Collections.Generic; +using System.Data; +using System.Linq; using FluentMigrator; +using NzbDrone.Common.Serializer; using NzbDrone.Core.Datastore.Migration.Framework; namespace NzbDrone.Core.Datastore.Migration @@ -14,7 +17,7 @@ namespace NzbDrone.Core.Datastore.Migration private void ConvertProfile(IDbConnection conn, IDbTransaction tran) { - var updater = new ProfileUpdater70(conn, tran); + var updater = new ProfileUpdater125(conn, tran); updater.SplitQualityAppend(0, 27); // TELECINE AFTER Unknown updater.SplitQualityAppend(0, 26); // TELESYNC AFTER Unknown updater.SplitQualityAppend(0, 25); // CAM AFTER Unknown @@ -32,4 +35,215 @@ namespace NzbDrone.Core.Datastore.Migration updater.Commit(); } } + + public class Profile125 + { + public int Id { get; set; } + public string Name { get; set; } + public int Cutoff { get; set; } + public List Items { get; set; } + public int Language { get; set; } + public List PreferredTags { get; set; } + } + + public class ProfileItem125 + { + public int? QualityDefinition { get; set; } + public int? Quality { get; set; } + public bool Allowed { get; set; } + } + + public class QualityDefinition125 + { + public int Id { get; set; } + public int Quality { get; set; } + } + + public class ProfileUpdater125 + { + private readonly IDbConnection _connection; + private readonly IDbTransaction _transaction; + + private List _profiles; + private HashSet _changedProfiles = new HashSet(); + + public ProfileUpdater125(IDbConnection conn, IDbTransaction tran) + { + _connection = conn; + _transaction = tran; + + _profiles = GetProfiles(); + } + + public void Commit() + { + foreach (var profile in _changedProfiles) + { + using (var updateProfileCmd = _connection.CreateCommand()) + { + updateProfileCmd.Transaction = _transaction; + updateProfileCmd.CommandText = "UPDATE Profiles SET Name = ?, Cutoff = ?, Items = ?, Language = ? WHERE Id = ?"; + updateProfileCmd.AddParameter(profile.Name); + updateProfileCmd.AddParameter(profile.Cutoff); + updateProfileCmd.AddParameter(profile.Items.ToJson()); + updateProfileCmd.AddParameter(profile.Language); + updateProfileCmd.AddParameter(profile.Id); + + updateProfileCmd.ExecuteNonQuery(); + } + } + + _changedProfiles.Clear(); + } + + public void PrependQuality(int quality) + { + foreach (var profile in _profiles) + { + if (profile.Items.Any(v => v.Quality == quality)) + { + continue; + } + + profile.Items.Insert(0, new ProfileItem125 + { + Quality = quality, + Allowed = false + }); + + _changedProfiles.Add(profile); + } + } + + public void AppendQuality(int quality) + { + foreach (var profile in _profiles) + { + if (profile.Items.Any(v => v.Quality == quality)) + { + continue; + } + + profile.Items.Add(new ProfileItem125 + { + Quality = quality, + Allowed = false + }); + + _changedProfiles.Add(profile); + } + } + + public void SplitQualityPrepend(int find, int quality) + { + foreach (var profile in _profiles) + { + if (profile.Items.Any(v => v.Quality == quality)) + { + continue; + } + + var findIndex = profile.Items.FindIndex(v => v.Quality == find); + + profile.Items.Insert(findIndex, new ProfileItem125 + { + Quality = quality, + Allowed = profile.Items[findIndex].Allowed + }); + + if (profile.Cutoff == find) + { + profile.Cutoff = quality; + } + + _changedProfiles.Add(profile); + } + } + + public void SplitQualityAppend(int find, int quality) + { + foreach (var profile in _profiles) + { + if (profile.Items.Any(v => v.Quality == quality)) + { + continue; + } + + var findIndex = profile.Items.FindIndex(v => v.Quality == find); + + profile.Items.Insert(findIndex + 1, new ProfileItem125 + { + Quality = quality, + Allowed = false + }); + + _changedProfiles.Add(profile); + } + } + + public void UpdateQualityToQualityDefinition() + { + var definitions = new List(); + using (var getDefinitions = _connection.CreateCommand()) + { + getDefinitions.Transaction = _transaction; + getDefinitions.CommandText = @"SELECT Id, Quality FROM QualityDefinitions"; + + using (var definitionsReader = getDefinitions.ExecuteReader()) + { + while (definitionsReader.Read()) + { + int id = definitionsReader.GetInt32(0); + int quality = definitionsReader.GetInt32(1); + definitions.Add(new QualityDefinition125 { Id = id, Quality = quality }); + } + } + } + + foreach (var profile in _profiles) + { + profile.Items = profile.Items.Select(i => + { + return new ProfileItem125 + { + Allowed = i.Allowed, + Quality = i.Quality, + QualityDefinition = definitions.Find(d => d.Quality == i.Quality).Id + }; + }).ToList(); + + profile.Cutoff = definitions.Find(d => d.Quality == profile.Cutoff).Id; + + _changedProfiles.Add(profile); + } + } + + private List GetProfiles() + { + var profiles = new List(); + + using (var getProfilesCmd = _connection.CreateCommand()) + { + getProfilesCmd.Transaction = _transaction; + getProfilesCmd.CommandText = @"SELECT Id, Name, Cutoff, Items, Language FROM Profiles"; + + using (var profileReader = getProfilesCmd.ExecuteReader()) + { + while (profileReader.Read()) + { + profiles.Add(new Profile125 + { + Id = profileReader.GetInt32(0), + Name = profileReader.GetString(1), + Cutoff = profileReader.GetInt32(2), + Items = Json.Deserialize>(profileReader.GetString(3)), + Language = profileReader.GetInt32(4) + }); + } + } + } + + return profiles; + } + } } diff --git a/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs b/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs index a04790fd8..0dfbc7f9f 100644 --- a/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs +++ b/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Datastore.Migration private void ConvertProfile(IDbConnection conn, IDbTransaction tran) { - var updater = new ProfileUpdater70(conn, tran); + var updater = new ProfileUpdater125(conn, tran); updater.SplitQualityAppend(19, 31); // Remux2160p AFTER Bluray2160p updater.SplitQualityAppend(7, 30); // Remux1080p AFTER Bluray1080p diff --git a/src/NzbDrone.Core/Datastore/Migration/156_add_download_client_priority.cs b/src/NzbDrone.Core/Datastore/Migration/156_add_download_client_priority.cs index 8d7349b5d..17533029e 100644 --- a/src/NzbDrone.Core/Datastore/Migration/156_add_download_client_priority.cs +++ b/src/NzbDrone.Core/Datastore/Migration/156_add_download_client_priority.cs @@ -52,4 +52,29 @@ namespace NzbDrone.Core.Datastore.Migration } } } + + public class DelugeSettings156 + { + public string Host { get; set; } + public int Port { get; set; } + public string UrlBase { get; set; } + public string Password { get; set; } + public string TvCategory { get; set; } + public int RecentTvPriority { get; set; } + public int OlderTvPriority { get; set; } + public bool UseSsl { get; set; } + } + + public class SabnzbdSettings156 + { + public string Host { get; set; } + public int Port { get; set; } + public string ApiKey { get; set; } + public string Username { get; set; } + public string Password { get; set; } + public string TvCategory { get; set; } + public int RecentTvPriority { get; set; } + public int OlderTvPriority { get; set; } + public bool UseSsl { get; set; } + } }