From 72ca3c6f180ba86ca6f8956462dcf55d5319cdc6 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 28 Jun 2020 22:15:06 -0400 Subject: [PATCH] Ensure new DBs match old DBs --- .../Datastore/Migration/001_initial_setup.cs | 36 +++++++++---------- ...parate_automatic_and_interactive_search.cs | 4 +-- .../Datastore/Migration/011_import_lists.cs | 2 +- .../013_album_download_notification.cs | 2 +- .../Migration/023_add_release_groups_etc.cs | 4 +-- .../Migration/025_rename_release_profiles.cs | 2 +- .../029_health_issue_notification.cs | 10 +++--- .../Migration/Framework/SqliteSchemaDumper.cs | 8 ++++- 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs index 7d6d9a190..4e698eaf0 100644 --- a/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs +++ b/src/NzbDrone.Core/Datastore/Migration/001_initial_setup.cs @@ -28,8 +28,8 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Overview").AsString().Nullable() .WithColumn("Images").AsString() .WithColumn("Path").AsString().Indexed() - .WithColumn("Monitored").AsBoolean() - .WithColumn("AlbumFolder").AsBoolean() + .WithColumn("Monitored").AsInt32() + .WithColumn("AlbumFolder").AsInt32() .WithColumn("LastInfoSync").AsDateTime().Nullable() .WithColumn("LastDiskSync").AsDateTime().Nullable() .WithColumn("DateFormed").AsDateTime().Nullable() @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Overview").AsString().Nullable() .WithColumn("Images").AsString() .WithColumn("Path").AsString().Indexed() - .WithColumn("Monitored").AsBoolean() + .WithColumn("Monitored").AsInt32() .WithColumn("LastInfoSync").AsDateTime().Nullable() .WithColumn("LastDiskSync").AsDateTime().Nullable() .WithColumn("ReleaseDate").AsDateTime().Nullable() @@ -82,11 +82,11 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("AlbumId").AsInt32() .WithColumn("TrackNumber").AsInt32() .WithColumn("Title").AsString().Nullable() - .WithColumn("Explicit").AsBoolean() - .WithColumn("Compilation").AsBoolean() + .WithColumn("Explicit").AsInt32() + .WithColumn("Compilation").AsInt32() .WithColumn("DiscNumber").AsInt32().Nullable() .WithColumn("TrackFileId").AsInt32().Nullable().Indexed() - .WithColumn("Monitored").AsBoolean() + .WithColumn("Monitored").AsInt32() .WithColumn("Ratings").AsString().Nullable() .WithColumn("Duration").AsInt32().WithDefaultValue(0); @@ -120,14 +120,14 @@ namespace NzbDrone.Core.Datastore.Migration Create.TableForModel("Notifications") .WithColumn("Name").AsString() - .WithColumn("OnGrab").AsBoolean() - .WithColumn("OnDownload").AsBoolean() + .WithColumn("OnGrab").AsInt32() + .WithColumn("OnDownload").AsInt32() .WithColumn("Settings").AsString() .WithColumn("Implementation").AsString() .WithColumn("ConfigContract").AsString().Nullable() - .WithColumn("OnUpgrade").AsBoolean().Nullable() + .WithColumn("OnUpgrade").AsInt32().Nullable() .WithColumn("Tags").AsString().Nullable() - .WithColumn("OnRename").AsBoolean().NotNullable(); + .WithColumn("OnRename").AsInt32().NotNullable(); Create.TableForModel("ScheduledTasks") .WithColumn("TypeName").AsString().Unique() @@ -139,8 +139,8 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Implementation").AsString() .WithColumn("Settings").AsString().Nullable() .WithColumn("ConfigContract").AsString().Nullable() - .WithColumn("EnableRss").AsBoolean().Nullable() - .WithColumn("EnableSearch").AsBoolean().Nullable(); + .WithColumn("EnableRss").AsInt32().Nullable() + .WithColumn("EnableSearch").AsInt32().Nullable(); Create.TableForModel("Profiles") .WithColumn("Name").AsString().Unique() @@ -154,9 +154,9 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("MaxSize").AsDouble().Nullable(); Create.TableForModel("NamingConfig") - .WithColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true) + .WithColumn("ReplaceIllegalCharacters").AsInt32().WithDefaultValue(true) .WithColumn("ArtistFolderFormat").AsString().Nullable() - .WithColumn("RenameTracks").AsBoolean().Nullable() + .WithColumn("RenameTracks").AsInt32().Nullable() .WithColumn("StandardTrackFormat").AsString().Nullable() .WithColumn("AlbumFolderFormat").AsString().Nullable(); @@ -175,7 +175,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("AlbumIds").AsString().WithDefaultValue(""); Create.TableForModel("Metadata") - .WithColumn("Enable").AsBoolean().NotNullable() + .WithColumn("Enable").AsInt32().NotNullable() .WithColumn("Name").AsString().NotNullable() .WithColumn("Implementation").AsString().NotNullable() .WithColumn("Settings").AsString().NotNullable() @@ -194,7 +194,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Extension").AsString().NotNullable(); Create.TableForModel("DownloadClients") - .WithColumn("Enable").AsBoolean().NotNullable() + .WithColumn("Enable").AsInt32().NotNullable() .WithColumn("Name").AsString().NotNullable() .WithColumn("Implementation").AsString().NotNullable() .WithColumn("Settings").AsString().NotNullable() @@ -222,8 +222,8 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Tags").AsString().NotNullable(); Create.TableForModel("DelayProfiles") - .WithColumn("EnableUsenet").AsBoolean().NotNullable() - .WithColumn("EnableTorrent").AsBoolean().NotNullable() + .WithColumn("EnableUsenet").AsInt32().NotNullable() + .WithColumn("EnableTorrent").AsInt32().NotNullable() .WithColumn("PreferredProtocol").AsInt32().NotNullable() .WithColumn("UsenetDelay").AsInt32().NotNullable() .WithColumn("TorrentDelay").AsInt32().NotNullable() diff --git a/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs b/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs index 3f03f8207..fd5767969 100644 --- a/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs +++ b/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs @@ -9,11 +9,11 @@ namespace NzbDrone.Core.Datastore.Migration protected override void MainDbUpgrade() { Rename.Column("EnableSearch").OnTable("Indexers").To("EnableAutomaticSearch"); - Alter.Table("Indexers").AddColumn("EnableInteractiveSearch").AsBoolean().Nullable(); + Alter.Table("Indexers").AddColumn("EnableInteractiveSearch").AsInt32().Nullable(); Execute.Sql("UPDATE Indexers SET EnableInteractiveSearch = EnableAutomaticSearch"); - Alter.Table("Indexers").AlterColumn("EnableInteractiveSearch").AsBoolean().NotNullable(); + Alter.Table("Indexers").AlterColumn("EnableInteractiveSearch").AsInt32().NotNullable(); } } } diff --git a/src/NzbDrone.Core/Datastore/Migration/011_import_lists.cs b/src/NzbDrone.Core/Datastore/Migration/011_import_lists.cs index 91de5e5f3..f9fd51829 100644 --- a/src/NzbDrone.Core/Datastore/Migration/011_import_lists.cs +++ b/src/NzbDrone.Core/Datastore/Migration/011_import_lists.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("Implementation").AsString() .WithColumn("Settings").AsString().Nullable() .WithColumn("ConfigContract").AsString().Nullable() - .WithColumn("EnableAutomaticAdd").AsBoolean().Nullable() + .WithColumn("EnableAutomaticAdd").AsInt32().Nullable() .WithColumn("RootFolderPath").AsString() .WithColumn("ShouldMonitor").AsInt32() .WithColumn("ProfileId").AsInt32() diff --git a/src/NzbDrone.Core/Datastore/Migration/013_album_download_notification.cs b/src/NzbDrone.Core/Datastore/Migration/013_album_download_notification.cs index 39bba97be..5209b9167 100644 --- a/src/NzbDrone.Core/Datastore/Migration/013_album_download_notification.cs +++ b/src/NzbDrone.Core/Datastore/Migration/013_album_download_notification.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.Datastore.Migration { protected override void MainDbUpgrade() { - Alter.Table("Notifications").AddColumn("OnAlbumDownload").AsBoolean().WithDefaultValue(0); + Alter.Table("Notifications").AddColumn("OnAlbumDownload").AsInt32().WithDefaultValue(0); } } } diff --git a/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs b/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs index 5e5a58c0a..7761a9766 100644 --- a/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs +++ b/src/NzbDrone.Core/Datastore/Migration/023_add_release_groups_etc.cs @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Datastore.Migration .WithColumn("ReleaseDate").AsDateTime().Nullable() .WithColumn("Media").AsString().Nullable() .WithColumn("TrackCount").AsInt32().Nullable() - .WithColumn("Monitored").AsBoolean(); + .WithColumn("Monitored").AsInt32(); Execute.WithConnection(PopulateReleases); @@ -64,7 +64,7 @@ namespace NzbDrone.Core.Datastore.Migration // Add in the extra columns and update artist metadata id Alter.Table("Albums").AddColumn("ArtistMetadataId").AsInt32().WithDefaultValue(0); - Alter.Table("Albums").AddColumn("AnyReleaseOk").AsBoolean().WithDefaultValue(true); + Alter.Table("Albums").AddColumn("AnyReleaseOk").AsInt32().WithDefaultValue(true); Alter.Table("Albums").AddColumn("Links").AsString().Nullable(); // Set metadata ID diff --git a/src/NzbDrone.Core/Datastore/Migration/025_rename_release_profiles.cs b/src/NzbDrone.Core/Datastore/Migration/025_rename_release_profiles.cs index b4f544c56..79c8d8602 100644 --- a/src/NzbDrone.Core/Datastore/Migration/025_rename_release_profiles.cs +++ b/src/NzbDrone.Core/Datastore/Migration/025_rename_release_profiles.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Datastore.Migration protected override void MainDbUpgrade() { Rename.Table("Restrictions").To("ReleaseProfiles"); - Alter.Table("ReleaseProfiles").AddColumn("IncludePreferredWhenRenaming").AsBoolean().WithDefaultValue(true); + Alter.Table("ReleaseProfiles").AddColumn("IncludePreferredWhenRenaming").AsInt32().WithDefaultValue(true); } } } diff --git a/src/NzbDrone.Core/Datastore/Migration/029_health_issue_notification.cs b/src/NzbDrone.Core/Datastore/Migration/029_health_issue_notification.cs index 4407daef6..696b78b41 100644 --- a/src/NzbDrone.Core/Datastore/Migration/029_health_issue_notification.cs +++ b/src/NzbDrone.Core/Datastore/Migration/029_health_issue_notification.cs @@ -9,11 +9,11 @@ namespace NzbDrone.Core.Datastore.Migration { protected override void MainDbUpgrade() { - Alter.Table("Notifications").AddColumn("OnHealthIssue").AsBoolean().WithDefaultValue(0); - Alter.Table("Notifications").AddColumn("IncludeHealthWarnings").AsBoolean().WithDefaultValue(0); - Alter.Table("Notifications").AddColumn("OnDownloadFailure").AsBoolean().WithDefaultValue(0); - Alter.Table("Notifications").AddColumn("OnImportFailure").AsBoolean().WithDefaultValue(0); - Alter.Table("Notifications").AddColumn("OnTrackRetag").AsBoolean().WithDefaultValue(0); + Alter.Table("Notifications").AddColumn("OnHealthIssue").AsInt32().WithDefaultValue(0); + Alter.Table("Notifications").AddColumn("IncludeHealthWarnings").AsInt32().WithDefaultValue(0); + Alter.Table("Notifications").AddColumn("OnDownloadFailure").AsInt32().WithDefaultValue(0); + Alter.Table("Notifications").AddColumn("OnImportFailure").AsInt32().WithDefaultValue(0); + Alter.Table("Notifications").AddColumn("OnTrackRetag").AsInt32().WithDefaultValue(0); Delete.Column("OnDownload").FromTable("Notifications"); diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs index 57b984c5a..358dc52b1 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Data; using FluentMigrator.Model; using FluentMigrator.Runner.Processors.SQLite; @@ -228,6 +228,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework case "BLOB": return DbType.Binary; case "INTEGER": + return DbType.Int32; + case "BIGINT": return DbType.Int64; case "NUMERIC": return DbType.Double; @@ -237,6 +239,10 @@ namespace NzbDrone.Core.Datastore.Migration.Framework return DbType.DateTime; case "UNIQUEIDENTIFIER": return DbType.Guid; + case "SMALLINT": + return DbType.Int16; + case "TINYINT": + return DbType.Boolean; default: return null; }