diff --git a/src/NzbDrone.Core.Test/Datastore/SqliteSchemaDumperTests/SqliteSchemaDumperFixture.cs b/src/NzbDrone.Core.Test/Datastore/SqliteSchemaDumperTests/SqliteSchemaDumperFixture.cs index b1ecba40f..a59bbf5a4 100644 --- a/src/NzbDrone.Core.Test/Datastore/SqliteSchemaDumperTests/SqliteSchemaDumperFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/SqliteSchemaDumperTests/SqliteSchemaDumperFixture.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data; using System.Linq; using FluentAssertions; using NUnit.Framework; @@ -38,6 +38,7 @@ namespace NzbDrone.Core.Test.Datastore.SqliteSchemaDumperTests result.Name.Should().Be(tableName); result.Columns.Count.Should().Be(1); result.Columns.First().Name.Should().Be(columnName); + result.Columns.First().IsIdentity.Should().BeTrue(); } [TestCase(@"CREATE INDEX TestIndex ON TestTable (MyId)", "TestIndex", "TestTable", "MyId")] diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs index 57b984c5a..4ae4e6e68 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Data; +using System.Linq; using FluentMigrator.Model; using FluentMigrator.Runner.Processors.SQLite; @@ -66,6 +67,24 @@ namespace NzbDrone.Core.Datastore.Migration.Framework if (columnReader.Read() == SqliteSyntaxReader.TokenType.StringToken) { + if (columnReader.ValueToUpper == "PRIMARY") + { + columnReader.SkipTillToken(SqliteSyntaxReader.TokenType.ListStart); + if (columnReader.Read() == SqliteSyntaxReader.TokenType.Identifier) + { + var pk = table.Columns.First(v => v.Name == columnReader.Value); + pk.IsPrimaryKey = true; + pk.IsNullable = true; + pk.IsUnique = true; + if (columnReader.Buffer.ToUpperInvariant().Contains("AUTOINCREMENT")) + { + pk.IsIdentity = true; + } + + continue; + } + } + if (columnReader.ValueToUpper == "CONSTRAINT" || columnReader.ValueToUpper == "PRIMARY" || columnReader.ValueToUpper == "UNIQUE" || columnReader.ValueToUpper == "CHECK" || columnReader.ValueToUpper == "FOREIGN")