Ensure new DBs match old DBs

This commit is contained in:
Qstick 2020-06-28 22:15:06 -04:00
commit 72ca3c6f18
8 changed files with 37 additions and 31 deletions

View file

@ -28,8 +28,8 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Overview").AsString().Nullable() .WithColumn("Overview").AsString().Nullable()
.WithColumn("Images").AsString() .WithColumn("Images").AsString()
.WithColumn("Path").AsString().Indexed() .WithColumn("Path").AsString().Indexed()
.WithColumn("Monitored").AsBoolean() .WithColumn("Monitored").AsInt32()
.WithColumn("AlbumFolder").AsBoolean() .WithColumn("AlbumFolder").AsInt32()
.WithColumn("LastInfoSync").AsDateTime().Nullable() .WithColumn("LastInfoSync").AsDateTime().Nullable()
.WithColumn("LastDiskSync").AsDateTime().Nullable() .WithColumn("LastDiskSync").AsDateTime().Nullable()
.WithColumn("DateFormed").AsDateTime().Nullable() .WithColumn("DateFormed").AsDateTime().Nullable()
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Overview").AsString().Nullable() .WithColumn("Overview").AsString().Nullable()
.WithColumn("Images").AsString() .WithColumn("Images").AsString()
.WithColumn("Path").AsString().Indexed() .WithColumn("Path").AsString().Indexed()
.WithColumn("Monitored").AsBoolean() .WithColumn("Monitored").AsInt32()
.WithColumn("LastInfoSync").AsDateTime().Nullable() .WithColumn("LastInfoSync").AsDateTime().Nullable()
.WithColumn("LastDiskSync").AsDateTime().Nullable() .WithColumn("LastDiskSync").AsDateTime().Nullable()
.WithColumn("ReleaseDate").AsDateTime().Nullable() .WithColumn("ReleaseDate").AsDateTime().Nullable()
@ -82,11 +82,11 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("AlbumId").AsInt32() .WithColumn("AlbumId").AsInt32()
.WithColumn("TrackNumber").AsInt32() .WithColumn("TrackNumber").AsInt32()
.WithColumn("Title").AsString().Nullable() .WithColumn("Title").AsString().Nullable()
.WithColumn("Explicit").AsBoolean() .WithColumn("Explicit").AsInt32()
.WithColumn("Compilation").AsBoolean() .WithColumn("Compilation").AsInt32()
.WithColumn("DiscNumber").AsInt32().Nullable() .WithColumn("DiscNumber").AsInt32().Nullable()
.WithColumn("TrackFileId").AsInt32().Nullable().Indexed() .WithColumn("TrackFileId").AsInt32().Nullable().Indexed()
.WithColumn("Monitored").AsBoolean() .WithColumn("Monitored").AsInt32()
.WithColumn("Ratings").AsString().Nullable() .WithColumn("Ratings").AsString().Nullable()
.WithColumn("Duration").AsInt32().WithDefaultValue(0); .WithColumn("Duration").AsInt32().WithDefaultValue(0);
@ -120,14 +120,14 @@ namespace NzbDrone.Core.Datastore.Migration
Create.TableForModel("Notifications") Create.TableForModel("Notifications")
.WithColumn("Name").AsString() .WithColumn("Name").AsString()
.WithColumn("OnGrab").AsBoolean() .WithColumn("OnGrab").AsInt32()
.WithColumn("OnDownload").AsBoolean() .WithColumn("OnDownload").AsInt32()
.WithColumn("Settings").AsString() .WithColumn("Settings").AsString()
.WithColumn("Implementation").AsString() .WithColumn("Implementation").AsString()
.WithColumn("ConfigContract").AsString().Nullable() .WithColumn("ConfigContract").AsString().Nullable()
.WithColumn("OnUpgrade").AsBoolean().Nullable() .WithColumn("OnUpgrade").AsInt32().Nullable()
.WithColumn("Tags").AsString().Nullable() .WithColumn("Tags").AsString().Nullable()
.WithColumn("OnRename").AsBoolean().NotNullable(); .WithColumn("OnRename").AsInt32().NotNullable();
Create.TableForModel("ScheduledTasks") Create.TableForModel("ScheduledTasks")
.WithColumn("TypeName").AsString().Unique() .WithColumn("TypeName").AsString().Unique()
@ -139,8 +139,8 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Implementation").AsString() .WithColumn("Implementation").AsString()
.WithColumn("Settings").AsString().Nullable() .WithColumn("Settings").AsString().Nullable()
.WithColumn("ConfigContract").AsString().Nullable() .WithColumn("ConfigContract").AsString().Nullable()
.WithColumn("EnableRss").AsBoolean().Nullable() .WithColumn("EnableRss").AsInt32().Nullable()
.WithColumn("EnableSearch").AsBoolean().Nullable(); .WithColumn("EnableSearch").AsInt32().Nullable();
Create.TableForModel("Profiles") Create.TableForModel("Profiles")
.WithColumn("Name").AsString().Unique() .WithColumn("Name").AsString().Unique()
@ -154,9 +154,9 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("MaxSize").AsDouble().Nullable(); .WithColumn("MaxSize").AsDouble().Nullable();
Create.TableForModel("NamingConfig") Create.TableForModel("NamingConfig")
.WithColumn("ReplaceIllegalCharacters").AsBoolean().WithDefaultValue(true) .WithColumn("ReplaceIllegalCharacters").AsInt32().WithDefaultValue(true)
.WithColumn("ArtistFolderFormat").AsString().Nullable() .WithColumn("ArtistFolderFormat").AsString().Nullable()
.WithColumn("RenameTracks").AsBoolean().Nullable() .WithColumn("RenameTracks").AsInt32().Nullable()
.WithColumn("StandardTrackFormat").AsString().Nullable() .WithColumn("StandardTrackFormat").AsString().Nullable()
.WithColumn("AlbumFolderFormat").AsString().Nullable(); .WithColumn("AlbumFolderFormat").AsString().Nullable();
@ -175,7 +175,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("AlbumIds").AsString().WithDefaultValue(""); .WithColumn("AlbumIds").AsString().WithDefaultValue("");
Create.TableForModel("Metadata") Create.TableForModel("Metadata")
.WithColumn("Enable").AsBoolean().NotNullable() .WithColumn("Enable").AsInt32().NotNullable()
.WithColumn("Name").AsString().NotNullable() .WithColumn("Name").AsString().NotNullable()
.WithColumn("Implementation").AsString().NotNullable() .WithColumn("Implementation").AsString().NotNullable()
.WithColumn("Settings").AsString().NotNullable() .WithColumn("Settings").AsString().NotNullable()
@ -194,7 +194,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Extension").AsString().NotNullable(); .WithColumn("Extension").AsString().NotNullable();
Create.TableForModel("DownloadClients") Create.TableForModel("DownloadClients")
.WithColumn("Enable").AsBoolean().NotNullable() .WithColumn("Enable").AsInt32().NotNullable()
.WithColumn("Name").AsString().NotNullable() .WithColumn("Name").AsString().NotNullable()
.WithColumn("Implementation").AsString().NotNullable() .WithColumn("Implementation").AsString().NotNullable()
.WithColumn("Settings").AsString().NotNullable() .WithColumn("Settings").AsString().NotNullable()
@ -222,8 +222,8 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Tags").AsString().NotNullable(); .WithColumn("Tags").AsString().NotNullable();
Create.TableForModel("DelayProfiles") Create.TableForModel("DelayProfiles")
.WithColumn("EnableUsenet").AsBoolean().NotNullable() .WithColumn("EnableUsenet").AsInt32().NotNullable()
.WithColumn("EnableTorrent").AsBoolean().NotNullable() .WithColumn("EnableTorrent").AsInt32().NotNullable()
.WithColumn("PreferredProtocol").AsInt32().NotNullable() .WithColumn("PreferredProtocol").AsInt32().NotNullable()
.WithColumn("UsenetDelay").AsInt32().NotNullable() .WithColumn("UsenetDelay").AsInt32().NotNullable()
.WithColumn("TorrentDelay").AsInt32().NotNullable() .WithColumn("TorrentDelay").AsInt32().NotNullable()

View file

@ -9,11 +9,11 @@ namespace NzbDrone.Core.Datastore.Migration
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Rename.Column("EnableSearch").OnTable("Indexers").To("EnableAutomaticSearch"); 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"); Execute.Sql("UPDATE Indexers SET EnableInteractiveSearch = EnableAutomaticSearch");
Alter.Table("Indexers").AlterColumn("EnableInteractiveSearch").AsBoolean().NotNullable(); Alter.Table("Indexers").AlterColumn("EnableInteractiveSearch").AsInt32().NotNullable();
} }
} }
} }

View file

@ -13,7 +13,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Implementation").AsString() .WithColumn("Implementation").AsString()
.WithColumn("Settings").AsString().Nullable() .WithColumn("Settings").AsString().Nullable()
.WithColumn("ConfigContract").AsString().Nullable() .WithColumn("ConfigContract").AsString().Nullable()
.WithColumn("EnableAutomaticAdd").AsBoolean().Nullable() .WithColumn("EnableAutomaticAdd").AsInt32().Nullable()
.WithColumn("RootFolderPath").AsString() .WithColumn("RootFolderPath").AsString()
.WithColumn("ShouldMonitor").AsInt32() .WithColumn("ShouldMonitor").AsInt32()
.WithColumn("ProfileId").AsInt32() .WithColumn("ProfileId").AsInt32()

View file

@ -8,7 +8,7 @@ namespace NzbDrone.Core.Datastore.Migration
{ {
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Alter.Table("Notifications").AddColumn("OnAlbumDownload").AsBoolean().WithDefaultValue(0); Alter.Table("Notifications").AddColumn("OnAlbumDownload").AsInt32().WithDefaultValue(0);
} }
} }
} }

View file

@ -56,7 +56,7 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("ReleaseDate").AsDateTime().Nullable() .WithColumn("ReleaseDate").AsDateTime().Nullable()
.WithColumn("Media").AsString().Nullable() .WithColumn("Media").AsString().Nullable()
.WithColumn("TrackCount").AsInt32().Nullable() .WithColumn("TrackCount").AsInt32().Nullable()
.WithColumn("Monitored").AsBoolean(); .WithColumn("Monitored").AsInt32();
Execute.WithConnection(PopulateReleases); Execute.WithConnection(PopulateReleases);
@ -64,7 +64,7 @@ namespace NzbDrone.Core.Datastore.Migration
// Add in the extra columns and update artist metadata id // Add in the extra columns and update artist metadata id
Alter.Table("Albums").AddColumn("ArtistMetadataId").AsInt32().WithDefaultValue(0); 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(); Alter.Table("Albums").AddColumn("Links").AsString().Nullable();
// Set metadata ID // Set metadata ID

View file

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Datastore.Migration
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Rename.Table("Restrictions").To("ReleaseProfiles"); Rename.Table("Restrictions").To("ReleaseProfiles");
Alter.Table("ReleaseProfiles").AddColumn("IncludePreferredWhenRenaming").AsBoolean().WithDefaultValue(true); Alter.Table("ReleaseProfiles").AddColumn("IncludePreferredWhenRenaming").AsInt32().WithDefaultValue(true);
} }
} }
} }

View file

@ -9,11 +9,11 @@ namespace NzbDrone.Core.Datastore.Migration
{ {
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Alter.Table("Notifications").AddColumn("OnHealthIssue").AsBoolean().WithDefaultValue(0); Alter.Table("Notifications").AddColumn("OnHealthIssue").AsInt32().WithDefaultValue(0);
Alter.Table("Notifications").AddColumn("IncludeHealthWarnings").AsBoolean().WithDefaultValue(0); Alter.Table("Notifications").AddColumn("IncludeHealthWarnings").AsInt32().WithDefaultValue(0);
Alter.Table("Notifications").AddColumn("OnDownloadFailure").AsBoolean().WithDefaultValue(0); Alter.Table("Notifications").AddColumn("OnDownloadFailure").AsInt32().WithDefaultValue(0);
Alter.Table("Notifications").AddColumn("OnImportFailure").AsBoolean().WithDefaultValue(0); Alter.Table("Notifications").AddColumn("OnImportFailure").AsInt32().WithDefaultValue(0);
Alter.Table("Notifications").AddColumn("OnTrackRetag").AsBoolean().WithDefaultValue(0); Alter.Table("Notifications").AddColumn("OnTrackRetag").AsInt32().WithDefaultValue(0);
Delete.Column("OnDownload").FromTable("Notifications"); Delete.Column("OnDownload").FromTable("Notifications");

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using FluentMigrator.Model; using FluentMigrator.Model;
using FluentMigrator.Runner.Processors.SQLite; using FluentMigrator.Runner.Processors.SQLite;
@ -228,6 +228,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
case "BLOB": case "BLOB":
return DbType.Binary; return DbType.Binary;
case "INTEGER": case "INTEGER":
return DbType.Int32;
case "BIGINT":
return DbType.Int64; return DbType.Int64;
case "NUMERIC": case "NUMERIC":
return DbType.Double; return DbType.Double;
@ -237,6 +239,10 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
return DbType.DateTime; return DbType.DateTime;
case "UNIQUEIDENTIFIER": case "UNIQUEIDENTIFIER":
return DbType.Guid; return DbType.Guid;
case "SMALLINT":
return DbType.Int16;
case "TINYINT":
return DbType.Boolean;
default: default:
return null; return null;
} }