From e4861283b65dded8702c25347d29d9d9c345d780 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 25 Dec 2012 00:05:13 -0800 Subject: [PATCH] SceneMappings now have season number --- .../Datastore/Migrations/Migration20121223.cs | 17 ++++++++++++++ NzbDrone.Core/Repository/SceneMapping.cs | 3 +++ .../Migrations/Migration20121223.cs | 22 +++++++++++++++++++ .../Providers/SceneMappingProvider.cs | 3 ++- .../Repository/SceneMapping.cs | 1 + 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 NzbDrone.Core/Datastore/Migrations/Migration20121223.cs create mode 100644 NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20121223.cs diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20121223.cs b/NzbDrone.Core/Datastore/Migrations/Migration20121223.cs new file mode 100644 index 000000000..a7a65ff6f --- /dev/null +++ b/NzbDrone.Core/Datastore/Migrations/Migration20121223.cs @@ -0,0 +1,17 @@ +using System; +using System.Data; +using Migrator.Framework; +using NzbDrone.Common; + +namespace NzbDrone.Core.Datastore.Migrations +{ + [Migration(20121223)] + public class Migration20121223 : NzbDroneMigration + { + protected override void MainDbUpgrade() + { + Database.AddColumn("SceneMappings", new Column("SeasonNumber", DbType.Int32, ColumnProperty.Null)); + Database.ExecuteNonQuery("UPDATE SceneMappings SET SeasonNumber = -1 WHERE SeasonNumber IS NULL"); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Repository/SceneMapping.cs b/NzbDrone.Core/Repository/SceneMapping.cs index 73bf07705..d32d0703d 100644 --- a/NzbDrone.Core/Repository/SceneMapping.cs +++ b/NzbDrone.Core/Repository/SceneMapping.cs @@ -14,5 +14,8 @@ namespace NzbDrone.Core.Repository [JsonProperty(PropertyName = "Title")] public string SceneName { get; set; } + + [JsonProperty(PropertyName = "Season")] + public int SeasonNumber { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20121223.cs b/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20121223.cs new file mode 100644 index 000000000..a31a007d8 --- /dev/null +++ b/NzbDrone.Services/NzbDrone.Services.Service/Migrations/Migration20121223.cs @@ -0,0 +1,22 @@ +using System; +using System.Data; +using System.Linq; +using Migrator.Framework; + +namespace NzbDrone.Services.Service.Migrations +{ + [Migration(20121223)] + public class Migration20121223 : Migration + { + public override void Up() + { + Database.AddColumn("SceneMappings", new Column("Season", DbType.Int32, ColumnProperty.Null)); + Database.ExecuteNonQuery("UPDATE SceneMappings SET Season = -1 WHERE Season IS NULL"); + } + + public override void Down() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Providers/SceneMappingProvider.cs b/NzbDrone.Services/NzbDrone.Services.Service/Providers/SceneMappingProvider.cs index 36daef8b1..df1e57c8b 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/Providers/SceneMappingProvider.cs +++ b/NzbDrone.Services/NzbDrone.Services.Service/Providers/SceneMappingProvider.cs @@ -69,7 +69,8 @@ namespace NzbDrone.Services.Service.Providers { CleanTitle = pendingItem.CleanTitle, Id = pendingItem.Id, - Title = pendingItem.Title + Title = pendingItem.Title, + Season = -1 }; Insert(mapping); diff --git a/NzbDrone.Services/NzbDrone.Services.Service/Repository/SceneMapping.cs b/NzbDrone.Services/NzbDrone.Services.Service/Repository/SceneMapping.cs index ad2177745..78ff66952 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/Repository/SceneMapping.cs +++ b/NzbDrone.Services/NzbDrone.Services.Service/Repository/SceneMapping.cs @@ -13,5 +13,6 @@ namespace NzbDrone.Services.Service.Repository public string CleanTitle { get; set; } public int Id { get; set; } public string Title { get; set; } + public int Season { get; set; } } } \ No newline at end of file