From 2c24f7ca04c7b05de4d23ee191522158d5f378a1 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 21 Dec 2021 18:09:05 -0600 Subject: [PATCH] Ensure Identity on Tables that have been modified --- .../Migration/177_language_improvements.cs | 2 +- .../204_ensure_identity_on_id_columns.cs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/204_ensure_identity_on_id_columns.cs diff --git a/src/NzbDrone.Core/Datastore/Migration/177_language_improvements.cs b/src/NzbDrone.Core/Datastore/Migration/177_language_improvements.cs index 2bb478795..481777acf 100644 --- a/src/NzbDrone.Core/Datastore/Migration/177_language_improvements.cs +++ b/src/NzbDrone.Core/Datastore/Migration/177_language_improvements.cs @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Datastore.Migration //Manual SQL, Fluent Migrator doesn't support multi-column unique contraint on table creation, SQLite doesn't support adding it after creation Execute.Sql("CREATE TABLE MovieTranslations(" + - "Id INTEGER PRIMARY KEY, " + + "Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " + "MovieId INTEGER NOT NULL, " + "Title TEXT, " + "CleanTitle TEXT, " + diff --git a/src/NzbDrone.Core/Datastore/Migration/204_ensure_identity_on_id_columns.cs b/src/NzbDrone.Core/Datastore/Migration/204_ensure_identity_on_id_columns.cs new file mode 100644 index 000000000..504ea3e61 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/204_ensure_identity_on_id_columns.cs @@ -0,0 +1,24 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(204)] + public class ensure_identity_on_id_columns : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Column("Id").OnTable("Movies").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("MovieTranslations").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("Commands").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("Credits").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("Profiles").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("PendingReleases").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("NamingConfig").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("History").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("Blocklist").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("MovieFiles").AsInt32().PrimaryKey().Identity(); + Alter.Column("Id").OnTable("CustomFormats").AsInt32().PrimaryKey().Identity(); + } + } +}