From bb5cc6509d65c6c80fa55afb97a3374eb4b61262 Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Thu, 25 Jul 2024 14:02:15 +1000 Subject: [PATCH] Updated to dbup-core 6.0 beta, targeted netstandard2 and update Sqlite reference --- src/Directory.Build.props | 14 ---- src/Sample/Program.cs | 4 +- src/Sample/Sample.csproj | 2 +- ...portTests.VerifyBasicSupport.approved.txt} | 4 +- ...JournalCreationIfNameChanged.approved.txt} | 4 +- ....VerifyVariableSubstitutions.approved.txt} | 4 +- .../NoPublicApiChanges.Run.DotNet.verified.cs | 77 ------------------- ....cs => NoPublicApiChanges.Run.approved.cs} | 1 - src/Tests/SQLiteSupportTests.cs | 19 ++--- src/Tests/SQLiteTableJournalTests.cs | 9 +-- src/Tests/Tests.csproj | 16 ++-- src/dbup-sqlite.sln.DotSettings | 3 + .../Helpers/InMemorySQLiteDatabase.cs | 26 +------ .../Helpers/TemporarySQLiteDatabase.cs | 49 ++---------- src/dbup-sqlite/SQLiteConnectionManager.cs | 12 +-- src/dbup-sqlite/SQLiteScriptExecutor.cs | 21 ++--- src/dbup-sqlite/dbup-sqlite.csproj | 21 ++--- 17 files changed, 56 insertions(+), 230 deletions(-) rename src/Tests/ApprovalFiles/{DatabaseSupportTests.VerifyBasicSupport.verified.txt => DatabaseSupportTests.VerifyBasicSupport.approved.txt} (92%) rename src/Tests/ApprovalFiles/{DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt => DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt} (92%) rename src/Tests/ApprovalFiles/{DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt => DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt} (92%) delete mode 100644 src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs rename src/Tests/ApprovalFiles/{NoPublicApiChanges.Run.Net.verified.cs => NoPublicApiChanges.Run.approved.cs} (99%) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d3b79f1..db1e7b7 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -10,18 +10,4 @@ latest true - - - - - true - - - true - - - embedded - - - diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs index 8957155..90bc3e8 100644 --- a/src/Sample/Program.cs +++ b/src/Sample/Program.cs @@ -87,15 +87,17 @@ static void Display(string dbType, DbUp.Engine.DatabaseUpgradeResult result, Tim "{0} Database Upgrade Runtime: {1}", dbType, string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)); + Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(result.Error); + Console.WriteLine("Press any key to continue..."); Console.ReadKey(); Console.WriteLine("Failed!"); } } } -} \ No newline at end of file +} diff --git a/src/Sample/Sample.csproj b/src/Sample/Sample.csproj index df2f803..ad8a65c 100644 --- a/src/Sample/Sample.csproj +++ b/src/Sample/Sample.csproj @@ -1,6 +1,6 @@  - net8.0 + net8 Exe false diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt similarity index 92% rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt index c49f705..df0e7a0 100644 --- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt +++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.approved.txt @@ -1,11 +1,11 @@ DB Operation: Open connection Info: Beginning database upgrade -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = 'SchemaVersions' DB Operation: Dispose command Info: Journal table does not exist Info: Executing Database Server script 'Script0001.sql' -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = 'SchemaVersions' DB Operation: Dispose command Info: Creating the [SchemaVersions] table diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt similarity index 92% rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt index 9434571..ee2f20b 100644 --- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt +++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.approved.txt @@ -1,11 +1,11 @@ DB Operation: Open connection Info: Beginning database upgrade -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = 'TestSchemaVersions' DB Operation: Dispose command Info: Journal table does not exist Info: Executing Database Server script 'Script0001.sql' -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = 'TestSchemaVersions' DB Operation: Dispose command Info: Creating the [TestSchemaVersions] table diff --git a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt similarity index 92% rename from src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt rename to src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt index 9bbd486..4bd02c0 100644 --- a/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt +++ b/src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.approved.txt @@ -1,11 +1,11 @@ DB Operation: Open connection Info: Beginning database upgrade -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = 'SchemaVersions' DB Operation: Dispose command Info: Journal table does not exist Info: Executing Database Server script 'Script0001.sql' -Info: Checking whether journal table exists.. +Info: Checking whether journal table exists DB Operation: Execute scalar command: SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = 'SchemaVersions' DB Operation: Dispose command Info: Creating the [SchemaVersions] table diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs deleted file mode 100644 index 15ac3ed..0000000 --- a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs +++ /dev/null @@ -1,77 +0,0 @@ -[assembly: System.CLSCompliantAttribute(true)] -[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] -[assembly: System.Runtime.InteropServices.GuidAttribute("9f949414-f078-49bf-b50e-a3859c18fb6e")] - -public static class SQLiteExtensions -{ - public static DbUp.Builder.UpgradeEngineBuilder JournalToSQLiteTable(this DbUp.Builder.UpgradeEngineBuilder builder, string table) { } - public static DbUp.Builder.UpgradeEngineBuilder SQLiteDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { } - public static DbUp.Builder.UpgradeEngineBuilder SQLiteDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.SQLite.Helpers.SharedConnection sharedConnection) { } -} -namespace DbUp.SQLite -{ - public class SQLiteConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager - { - public SQLiteConnectionManager(string connectionString) { } - public SQLiteConnectionManager(DbUp.SQLite.Helpers.SharedConnection sharedConnection) { } - public override System.Collections.Generic.IEnumerable SplitScriptIntoCommands(string scriptContents) { } - } - public class SQLiteObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser - { - public SQLiteObjectParser() { } - } - public class SQLitePreprocessor : DbUp.Engine.IScriptPreprocessor - { - public SQLitePreprocessor() { } - public string Process(string contents) { } - } - public class SQLiteScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor - { - public SQLiteScriptExecutor(System.Func connectionManagerFactory, System.Func log, string schema, System.Func variablesEnabled, System.Collections.Generic.IEnumerable scriptPreprocessors, System.Func journalFactory) { } - protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { } - protected override string GetVerifySchemaSql(string schema) { } - } - public class SQLiteTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal - { - public SQLiteTableJournal(System.Func connectionManager, System.Func logger, string table) { } - protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { } - protected override string DoesTableExistSql() { } - protected override string GetInsertJournalEntrySql(string scriptName, string applied) { } - protected override string GetJournalEntriesSql() { } - } -} -namespace DbUp.SQLite.Helpers -{ - public class InMemorySQLiteDatabase : System.IDisposable - { - public InMemorySQLiteDatabase() { } - public string ConnectionString { get; set; } - public DbUp.Helpers.AdHocSqlRunner SqlRunner { get; } - public void Dispose() { } - public DbUp.Engine.Transactions.IConnectionManager GetConnectionManager() { } - } - public class SharedConnection : System.Data.IDbConnection, System.IDisposable - { - public SharedConnection(System.Data.IDbConnection dbConnection) { } - public string ConnectionString { get; set; } - public int ConnectionTimeout { get; } - public string Database { get; } - public System.Data.ConnectionState State { get; } - public System.Data.IDbTransaction BeginTransaction() { } - public System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il) { } - public void ChangeDatabase(string databaseName) { } - public void Close() { } - public System.Data.IDbCommand CreateCommand() { } - public void Dispose() { } - public void DoClose() { } - public void Open() { } - } - public class TemporarySQLiteDatabase : System.IDisposable - { - public TemporarySQLiteDatabase(string name) { } - public DbUp.SQLite.Helpers.SharedConnection SharedConnection { get; } - public DbUp.Helpers.AdHocSqlRunner SqlRunner { get; } - public void Create() { } - public void Dispose() { } - } -} diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs similarity index 99% rename from src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs rename to src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs index 15ac3ed..b691b30 100644 --- a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs +++ b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs @@ -71,7 +71,6 @@ public class TemporarySQLiteDatabase : System.IDisposable public TemporarySQLiteDatabase(string name) { } public DbUp.SQLite.Helpers.SharedConnection SharedConnection { get; } public DbUp.Helpers.AdHocSqlRunner SqlRunner { get; } - public void Create() { } public void Dispose() { } } } diff --git a/src/Tests/SQLiteSupportTests.cs b/src/Tests/SQLiteSupportTests.cs index bd0d553..0b32f7d 100644 --- a/src/Tests/SQLiteSupportTests.cs +++ b/src/Tests/SQLiteSupportTests.cs @@ -1,7 +1,5 @@ -#if !NETCORE -using System; -using System.Data.SQLite; -using System.IO; +using Microsoft.Data.Sqlite; +using Shouldly; using Xunit; namespace DbUp.SQLite.Tests @@ -13,18 +11,17 @@ public class SQLiteSupportTests [Fact] public void CanUseSQLite() { - var connectionString = string.Format("Data Source={0}; Version=3;", dbFilePath); - - if (!File.Exists(dbFilePath)) - { - SQLiteConnection.CreateFile(dbFilePath); - } + var connectionString = $"Data Source={dbFilePath}"; var upgrader = DeployChanges.To .SQLiteDatabase(connectionString) .WithScript("Script0001", "CREATE TABLE IF NOT EXISTS Foo (Id int)") .Build(); + + var result = upgrader.PerformUpgrade(); + + result.Error.ShouldBe(null); + result.Successful.ShouldBe(true); } } } -#endif diff --git a/src/Tests/SQLiteTableJournalTests.cs b/src/Tests/SQLiteTableJournalTests.cs index ce0171a..151aed8 100644 --- a/src/Tests/SQLiteTableJournalTests.cs +++ b/src/Tests/SQLiteTableJournalTests.cs @@ -1,11 +1,9 @@ -#if !NETCORE -using System.Collections.Generic; -using System.Data; -using System.Data.SQLite; +using System.Data; using DbUp.Engine; using DbUp.Engine.Output; using DbUp.Engine.Transactions; using DbUp.Tests.Common; +using Microsoft.Data.Sqlite; using NSubstitute; using Shouldly; using Xunit; @@ -22,7 +20,7 @@ public void dbversion_is_zero_when_journal_table_not_exist() var command = Substitute.For(); dbConnection.CreateCommand().Returns(command); var connectionManager = Substitute.For(); - command.ExecuteScalar().Returns(x => { throw new SQLiteException("table not found"); }); + command.ExecuteScalar().Returns(x => { throw new SqliteException("table not found", 0); }); var consoleUpgradeLog = new ConsoleUpgradeLog(); var journal = new SQLiteTableJournal(() => connectionManager, () => consoleUpgradeLog, "SchemaVersions"); @@ -62,4 +60,3 @@ public void creates_a_new_journal_table_when_not_exist() } } } -#endif diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 3a39421..219abda 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,23 +1,19 @@ - net462;net8 + net8 Tests DbUp.SQLite.Tests - + enable enable - - $(DefineConstants);NETCORE - - - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/dbup-sqlite.sln.DotSettings b/src/dbup-sqlite.sln.DotSettings index 2c78c0a..d3334fb 100644 --- a/src/dbup-sqlite.sln.DotSettings +++ b/src/dbup-sqlite.sln.DotSettings @@ -5,5 +5,8 @@ SQ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + True <data><IncludeFilters /><ExcludeFilters /></data> <data /> \ No newline at end of file diff --git a/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs b/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs index 16bec7b..8e3dfb3 100644 --- a/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs +++ b/src/dbup-sqlite/Helpers/InMemorySQLiteDatabase.cs @@ -1,17 +1,8 @@ using System; using DbUp.Engine.Transactions; using DbUp.Helpers; +using Microsoft.Data.Sqlite; -#if MONO -using SQLiteConnection = Mono.Data.Sqlite.SqliteConnection; -using SQLiteConnectionStringBuilder = Mono.Data.Sqlite.SqliteConnectionStringBuilder; -using SQLiteJournalModeEnum = Mono.Data.Sqlite.SQLiteJournalModeEnum; -#elif NETCORE -using SQLiteConnection = Microsoft.Data.Sqlite.SqliteConnection; -using SQLiteConnectionStringBuilder = Microsoft.Data.Sqlite.SqliteConnectionStringBuilder; -#else -using System.Data.SQLite; -#endif namespace DbUp.SQLite.Helpers { @@ -21,31 +12,22 @@ namespace DbUp.SQLite.Helpers public class InMemorySQLiteDatabase : IDisposable { readonly SQLiteConnectionManager connectionManager; - readonly SQLiteConnection sharedConnection; + readonly SqliteConnection sharedConnection; /// /// Initializes a new instance of the class. /// public InMemorySQLiteDatabase() { - var connectionStringBuilder = new SQLiteConnectionStringBuilder + var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = ":memory:", -#if !NETCORE - Version = 3, DefaultTimeout = 5, -#if MONO - JournalMode = SQLiteJournalModeEnum.Off, -#else - JournalMode = SQLiteJournalModeEnum.Memory, -#endif - UseUTF16Encoding = true -#endif }; ConnectionString = connectionStringBuilder.ToString(); connectionManager = new SQLiteConnectionManager(connectionStringBuilder.ConnectionString); - sharedConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString); + sharedConnection = new SqliteConnection(connectionStringBuilder.ConnectionString); sharedConnection.Open(); SqlRunner = new AdHocSqlRunner(() => sharedConnection.CreateCommand(), new SQLiteObjectParser(), null, () => true); } diff --git a/src/dbup-sqlite/Helpers/TemporarySQLiteDatabase.cs b/src/dbup-sqlite/Helpers/TemporarySQLiteDatabase.cs index e1d1911..80cbac3 100644 --- a/src/dbup-sqlite/Helpers/TemporarySQLiteDatabase.cs +++ b/src/dbup-sqlite/Helpers/TemporarySQLiteDatabase.cs @@ -1,17 +1,8 @@ using System; using System.IO; using DbUp.Helpers; +using Microsoft.Data.Sqlite; -#if MONO -using SQLiteConnection = Mono.Data.Sqlite.SqliteConnection; -using SQLiteConnectionStringBuilder = Mono.Data.Sqlite.SqliteConnectionStringBuilder; -using SQLiteJournalModeEnum = Mono.Data.Sqlite.SQLiteJournalModeEnum; -#elif NETCORE -using SQLiteConnection = Microsoft.Data.Sqlite.SqliteConnection; -using SQLiteConnectionStringBuilder = Microsoft.Data.Sqlite.SqliteConnectionStringBuilder; -#else -using System.Data.SQLite; -#endif namespace DbUp.SQLite.Helpers { @@ -21,7 +12,7 @@ namespace DbUp.SQLite.Helpers public class TemporarySQLiteDatabase : IDisposable { readonly string dataSourcePath; - readonly SQLiteConnection sqLiteConnection; + readonly SqliteConnection sqLiteConnection; /// /// Initializes a new instance of the class. @@ -31,22 +22,13 @@ public TemporarySQLiteDatabase(string name) { dataSourcePath = Path.Combine(Directory.GetCurrentDirectory(), name); - var connectionStringBuilder = new SQLiteConnectionStringBuilder + var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = name, -#if !NETCORE - Version = 3, DefaultTimeout = 5, -#if MONO - JournalMode = SQLiteJournalModeEnum.Off, -#else - JournalMode = SQLiteJournalModeEnum.Memory, -#endif - UseUTF16Encoding = true -#endif }; - sqLiteConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString); + sqLiteConnection = new SqliteConnection(connectionStringBuilder.ConnectionString); sqLiteConnection.Open(); SharedConnection = new SharedConnection(sqLiteConnection); SqlRunner = new AdHocSqlRunner(() => sqLiteConnection.CreateCommand(), new SQLiteObjectParser(), null, () => true); @@ -59,20 +41,6 @@ public TemporarySQLiteDatabase(string name) public SharedConnection SharedConnection { get; } - /// - /// Creates the database. - /// - public void Create() - { -#if !NETCORE - var filePath = new FileInfo(dataSourcePath); - if (!filePath.Exists) - { - SQLiteConnection.CreateFile(dataSourcePath); - } -#endif - } - /// /// Deletes the database. /// @@ -82,14 +50,11 @@ public void Dispose() if (!filePath.Exists) return; SharedConnection.Dispose(); sqLiteConnection.Dispose(); -#if !NETCORE - SQLiteConnection.ClearAllPools(); - + // SQLite requires all created sql connection/command objects to be disposed // in order to delete the database file - GC.Collect(2, GCCollectionMode.Forced); - System.Threading.Thread.Sleep(100); -#endif + SqliteConnection.ClearAllPools(); + File.Delete(dataSourcePath); } } diff --git a/src/dbup-sqlite/SQLiteConnectionManager.cs b/src/dbup-sqlite/SQLiteConnectionManager.cs index 29f6edc..133ec6e 100644 --- a/src/dbup-sqlite/SQLiteConnectionManager.cs +++ b/src/dbup-sqlite/SQLiteConnectionManager.cs @@ -3,13 +3,7 @@ using System.Text.RegularExpressions; using DbUp.Engine.Transactions; using DbUp.SQLite.Helpers; -#if MONO -using SQLiteConnection = Mono.Data.Sqlite.SqliteConnection; -#elif NETCORE -using SQLiteConnection = Microsoft.Data.Sqlite.SqliteConnection; -#else -using System.Data.SQLite; -#endif +using Microsoft.Data.Sqlite; namespace DbUp.SQLite { @@ -21,7 +15,7 @@ public class SQLiteConnectionManager : DatabaseConnectionManager /// /// Creates new SQLite Connection Manager /// - public SQLiteConnectionManager(string connectionString) : base(l => new SQLiteConnection(connectionString)) + public SQLiteConnectionManager(string connectionString) : base(l => new SqliteConnection(connectionString)) { } @@ -46,4 +40,4 @@ public override IEnumerable SplitScriptIntoCommands(string scriptContent return scriptStatements; } } -} \ No newline at end of file +} diff --git a/src/dbup-sqlite/SQLiteScriptExecutor.cs b/src/dbup-sqlite/SQLiteScriptExecutor.cs index 741b52f..d966615 100644 --- a/src/dbup-sqlite/SQLiteScriptExecutor.cs +++ b/src/dbup-sqlite/SQLiteScriptExecutor.cs @@ -4,14 +4,7 @@ using DbUp.Engine.Output; using DbUp.Engine.Transactions; using DbUp.Support; - -#if MONO -using SQLiteException = Mono.Data.Sqlite.SqliteException; -#elif NETCORE -using SQLiteException = Microsoft.Data.Sqlite.SqliteException; -#else -using System.Data.SQLite; -#endif +using Microsoft.Data.Sqlite; namespace DbUp.SQLite { @@ -46,15 +39,11 @@ protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScri { executeCommand(); } - catch (SQLiteException exception) + catch (SqliteException exception) { - Log().WriteInformation("SQLite exception has occurred in script: '{0}'", script.Name); -#if NETCORE - Log().WriteError("Script block number: {0}; Error Code: {1}; Message: {2}", index, exception.SqliteErrorCode, exception.Message); -#else - Log().WriteError("Script block number: {0}; Error Code: {1}; Message: {2}", index, exception.ErrorCode, exception.Message); -#endif - Log().WriteError(exception.ToString()); + Log().LogInformation("SQLite exception has occurred in script: '{0}'", script.Name); + Log().LogError("Script block number: {0}; Error Code: {1}; Message: {2}", index, exception.SqliteErrorCode, exception.Message); + Log().LogError(exception.ToString()); throw; } } diff --git a/src/dbup-sqlite/dbup-sqlite.csproj b/src/dbup-sqlite/dbup-sqlite.csproj index da35aad..9215449 100644 --- a/src/dbup-sqlite/dbup-sqlite.csproj +++ b/src/dbup-sqlite/dbup-sqlite.csproj @@ -6,7 +6,7 @@ DbUp Contributors DbUp Copyright © DbUp Contributors 2015 - netstandard1.3;net462 + netstandard2.0 dbup-sqlite DbUp.SQLite dbup-sqlite @@ -16,22 +16,15 @@ dbup-icon.png - - $(DefineConstants);NETCORE + + true + true + embedded - - - - - - - - - - - + +