From 22636bb762a224a3d73b84f2eace19fff0bf1c3f Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 27 Jun 2023 21:07:08 -0500 Subject: [PATCH] Fixed: Correct typing for ImportListExclusions tvdbid column (cherry picked from commit af8c67a24d343ba4640400886ee940d5be5ce55f) --- .../192_import_exclusion_typeFixture.cs | 41 +++++++++++++++++++ .../Migration/192_import_exclusion_type.cs | 14 +++++++ 2 files changed, 55 insertions(+) create mode 100644 src/NzbDrone.Core.Test/Datastore/Migration/192_import_exclusion_typeFixture.cs create mode 100644 src/NzbDrone.Core/Datastore/Migration/192_import_exclusion_type.cs diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/192_import_exclusion_typeFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/192_import_exclusion_typeFixture.cs new file mode 100644 index 000000000..19729798b --- /dev/null +++ b/src/NzbDrone.Core.Test/Datastore/Migration/192_import_exclusion_typeFixture.cs @@ -0,0 +1,41 @@ +using System.Linq; +using Dapper; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Datastore.Migration; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore.Migration +{ + [TestFixture] + public class import_exclusion_typeFixture : MigrationTest + { + [Test] + public void should_alter_tvdbid_column() + { + var db = WithDapperMigrationTestDb(c => + { + c.Insert.IntoTable("ImportListExclusions").Row(new + { + TvdbId = "1", + Title = "Some Series" + }); + }); + + // Should be able to insert as int after migration + db.Execute("INSERT INTO ImportListExclusions (TvdbId, Title) VALUES (2, 'Some Other Series')"); + + var exclusions = db.Query("SELECT * FROM ImportListExclusions"); + + exclusions.Should().HaveCount(2); + exclusions.First().TvdbId.Should().Be(1); + } + } + + public class ImportListExclusions192 + { + public int Id { get; set; } + public int TvdbId { get; set; } + public string Title { get; set; } + } +} diff --git a/src/NzbDrone.Core/Datastore/Migration/192_import_exclusion_type.cs b/src/NzbDrone.Core/Datastore/Migration/192_import_exclusion_type.cs new file mode 100644 index 000000000..8b59ec4dc --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/192_import_exclusion_type.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(192)] + public class import_exclusion_type : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("ImportListExclusions").AlterColumn("TvdbId").AsInt32(); + } + } +}