diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs index abc1013..cd63b1c 100644 --- a/src/Sample/Program.cs +++ b/src/Sample/Program.cs @@ -7,8 +7,8 @@ public static class Program { static void Main() { - InMemoryDb(); - TemporaryFileDb(); + //InMemoryDb(); + //TemporaryFileDb(); PermanentFileDb(); } @@ -56,7 +56,7 @@ static void TemporaryFileDb() static void PermanentFileDb() { - SqliteConnection connection = new("Data Source=dbup.db"); + SqliteConnection connection = new("Data Source=dbup.db;"); using (var database = new DbUp.Sqlite.Helpers.SharedConnection(connection)) { diff --git a/src/dbup-sqlite/Helpers/InMemorySqliteDatabase.cs b/src/dbup-sqlite/Helpers/InMemorySqliteDatabase.cs index d4a3a38..715232e 100644 --- a/src/dbup-sqlite/Helpers/InMemorySqliteDatabase.cs +++ b/src/dbup-sqlite/Helpers/InMemorySqliteDatabase.cs @@ -1,4 +1,4 @@ -using System; +using System; using DbUp.Engine.Transactions; using DbUp.Helpers; using Microsoft.Data.Sqlite; @@ -33,6 +33,9 @@ public InMemorySqliteDatabase() SqlRunner = new AdHocSqlRunner(() => sharedConnection.CreateCommand(), new SqliteObjectParser(), null, () => true); } + /// + /// Gets or sets the connection string for the in-memory database. + /// public string ConnectionString { get; set; } /// diff --git a/src/dbup-sqlite/Helpers/SharedConnection.cs b/src/dbup-sqlite/Helpers/SharedConnection.cs index 3540479..af99ad2 100644 --- a/src/dbup-sqlite/Helpers/SharedConnection.cs +++ b/src/dbup-sqlite/Helpers/SharedConnection.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; namespace DbUp.Sqlite.Helpers @@ -30,36 +30,50 @@ public SharedConnection(IDbConnection dbConnection) connection.Open(); } + /// public IDbTransaction BeginTransaction(IsolationLevel il) => connection.BeginTransaction(il); + /// public IDbTransaction BeginTransaction() => connection.BeginTransaction(); + /// public void ChangeDatabase(string databaseName) => connection.ChangeDatabase(databaseName); + /// public void Close() { } // shared underlying connection is not closed + /// public string ConnectionString { get => connection.ConnectionString; set => connection.ConnectionString = value; } + /// public int ConnectionTimeout => connection.ConnectionTimeout; + /// public IDbCommand CreateCommand() => connection.CreateCommand(); + /// public string Database => connection.Database; + /// public void Open() { if (connection.State == ConnectionState.Closed) connection.Open(); } + /// public ConnectionState State => connection.State; + /// public void Dispose() { } // shared underlying connection is not disposed + /// + /// Closes the connection if it was opened by this wrapper. + /// public void DoClose() { // if shared underlying connection is opened by this object diff --git a/src/dbup-sqlite/Helpers/TemporarySqliteDatabase.cs b/src/dbup-sqlite/Helpers/TemporarySqliteDatabase.cs index 2626f03..526fb42 100644 --- a/src/dbup-sqlite/Helpers/TemporarySqliteDatabase.cs +++ b/src/dbup-sqlite/Helpers/TemporarySqliteDatabase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using DbUp.Helpers; using Microsoft.Data.Sqlite; @@ -39,6 +39,9 @@ public TemporarySqliteDatabase(string name) /// public AdHocSqlRunner SqlRunner { get; } + /// + /// Gets the shared connection used by this temporary database. + /// public SharedConnection SharedConnection { get; } /// diff --git a/src/dbup-sqlite/SqliteConnectionManager.cs b/src/dbup-sqlite/SqliteConnectionManager.cs index af3191b..8fdb657 100644 --- a/src/dbup-sqlite/SqliteConnectionManager.cs +++ b/src/dbup-sqlite/SqliteConnectionManager.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using DbUp.Engine.Transactions; @@ -26,9 +26,7 @@ public SqliteConnectionManager(SharedConnection sharedConnection) : base(l => sh { } - /// - /// Sqlite statements separator is ; (see http://www.sqlite.org/lang.html) - /// + /// public override IEnumerable SplitScriptIntoCommands(string scriptContents) { var scriptStatements = diff --git a/src/dbup-sqlite/SqliteExtensions.cs b/src/dbup-sqlite/SqliteExtensions.cs index 7c35462..b692411 100644 --- a/src/dbup-sqlite/SqliteExtensions.cs +++ b/src/dbup-sqlite/SqliteExtensions.cs @@ -1,4 +1,4 @@ -using DbUp.Builder; +using DbUp.Builder; using DbUp.Sqlite; using DbUp.Sqlite.Helpers; @@ -53,6 +53,7 @@ public static UpgradeEngineBuilder SqliteDatabase(this SupportedDatabases suppor /// /// Tracks the list of executed scripts in a custom SQLite table. /// + /// The builder. /// The name of the table used to store the list of executed scripts. /// The used to set the journal table name. public static UpgradeEngineBuilder JournalToSqliteTable(this UpgradeEngineBuilder builder, string table) diff --git a/src/dbup-sqlite/SqliteObjectParser.cs b/src/dbup-sqlite/SqliteObjectParser.cs index 2d674d6..1608098 100644 --- a/src/dbup-sqlite/SqliteObjectParser.cs +++ b/src/dbup-sqlite/SqliteObjectParser.cs @@ -1,4 +1,4 @@ -using DbUp.Support; +using DbUp.Support; namespace DbUp.Sqlite { @@ -7,6 +7,9 @@ namespace DbUp.Sqlite /// public class SqliteObjectParser : SqlObjectParser { + /// + /// Initializes a new instance of the class. + /// public SqliteObjectParser() : base("[", "]") { diff --git a/src/dbup-sqlite/SqliteScriptExecutor.cs b/src/dbup-sqlite/SqliteScriptExecutor.cs index 9b0ed03..154edbd 100644 --- a/src/dbup-sqlite/SqliteScriptExecutor.cs +++ b/src/dbup-sqlite/SqliteScriptExecutor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using DbUp.Engine; using DbUp.Engine.Output; @@ -28,11 +28,13 @@ public SqliteScriptExecutor(Func connectionManagerFactory, F { } + /// protected override string GetVerifySchemaSql(string schema) { throw new NotSupportedException(); } + /// protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScript script, Action executeCommand) { try diff --git a/src/dbup-sqlite/SqliteTableJournal.cs b/src/dbup-sqlite/SqliteTableJournal.cs index 92c6d23..cb197fb 100644 --- a/src/dbup-sqlite/SqliteTableJournal.cs +++ b/src/dbup-sqlite/SqliteTableJournal.cs @@ -1,4 +1,4 @@ -using System; +using System; using DbUp.Engine; using DbUp.Engine.Output; using DbUp.Engine.Transactions; @@ -15,20 +15,26 @@ public class SqliteTableJournal : TableJournal /// /// Initializes a new instance of the class. /// + /// The connection manager. + /// The log. + /// The table name. public SqliteTableJournal(Func connectionManager, Func logger, string table) : base(connectionManager, logger, new SqliteObjectParser(), null, table) { } + /// protected override string GetInsertJournalEntrySql(string @scriptName, string @applied) { return $"insert into {FqSchemaTableName} (ScriptName, Applied) values ({@scriptName}, {@applied})"; } + /// protected override string GetJournalEntriesSql() { return $"select [ScriptName] from {FqSchemaTableName} order by [ScriptName]"; } + /// protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { return @@ -39,6 +45,7 @@ Applied DATETIME NOT NULL )"; } + /// protected override string DoesTableExistSql() { return $"SELECT count(name) FROM sqlite_master WHERE type = 'table' AND name = '{UnquotedSchemaTableName}'"; diff --git a/src/dbup-sqlite/dbup-sqlite.csproj b/src/dbup-sqlite/dbup-sqlite.csproj index 8220aad..aadb4c0 100644 --- a/src/dbup-sqlite/dbup-sqlite.csproj +++ b/src/dbup-sqlite/dbup-sqlite.csproj @@ -1,4 +1,4 @@ - + DbUp makes it easy to deploy and upgrade SQL Server databases. This package adds SQLite support. @@ -14,6 +14,7 @@ true https://github.com/DbUp/dbup-sqlite.git dbup-icon.png + true