From f7163451e12228f95d74dd675fea394d63416ac6 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 17 Dec 2019 21:57:51 -0500 Subject: [PATCH] New: Keep DB Migration to fix 147 Co-Authored-By: ta264 --- .../162_fix_profile_format_default.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/NzbDrone.Core/Datastore/Migration/162_fix_profile_format_default.cs diff --git a/src/NzbDrone.Core/Datastore/Migration/162_fix_profile_format_default.cs b/src/NzbDrone.Core/Datastore/Migration/162_fix_profile_format_default.cs new file mode 100644 index 000000000..8ee7ee293 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/162_fix_profile_format_default.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(162)] + public class fix_profile_format_default : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + // badValue was set as default in 147 but it's invalid JSON + // so System.Text.Json refuses to parse it (even though Newtonsoft allows it) + var badValue = "[{format:0, allowed:true}]"; + var defaultValue = "[{\"format\":0, \"allowed\":true}]"; + Alter.Column("FormatItems").OnTable("Profiles").AsString().WithDefaultValue(defaultValue); + + Update.Table("Profiles").Set(new { FormatItems = defaultValue }).Where(new { FormatItems = badValue }); + } + } +} \ No newline at end of file