generated from DbUp/dbup-provider-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
652 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using Microsoft.Extensions.Configuration; | ||
using DbUp; | ||
|
||
namespace FirebirdSampleApplication | ||
{ | ||
class Program | ||
{ | ||
static int Main() | ||
{ | ||
var config = GetConfig(); | ||
string connectionString = config.GetConnectionString("SampleFirebird"); | ||
|
||
var upgrader = | ||
DeployChanges.To | ||
.FirebirdDatabase(connectionString) | ||
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()) | ||
.WithTransactionPerScript() | ||
.LogToConsole() | ||
.Build(); | ||
|
||
var result = upgrader.PerformUpgrade(); | ||
|
||
if (!result.Successful) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine(result.Error); | ||
Console.ResetColor(); | ||
|
||
WaitIfDebug(); | ||
return -1; | ||
} | ||
|
||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine("Success!"); | ||
Console.ResetColor(); | ||
WaitIfDebug(); | ||
return 0; | ||
} | ||
|
||
private static IConfiguration GetConfig() | ||
{ | ||
IConfiguration config = new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json", true, true) | ||
.Build(); | ||
return config; | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
public static void WaitIfDebug() | ||
{ | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net7.0</TargetFrameworks> | ||
<OutputType>Exe</OutputType> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\dbup-firebird\dbup-firebird.csproj"/> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Scripts\*.sql"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE TABLE Testing1 (ID integer NOT NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE TABLE Testing2 (ID integer NOT NULL) | ||
; | ||
CREATE TABLE Testing3 (ID integer NOT NULL) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE TABLE Testing4 (ID integer NOT NULL) | ||
; | ||
CREATE TABLE Testing5 (ID integer NOT NULL) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE TABLE Testing6 (ID integer NOT NULL) | ||
; | ||
CREATE TABLE Testing7 (ID integer NOT NULL) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ConnectionStrings": { | ||
"SampleFirebird": "User=SOMEUSER;Password=SOMEPWD;Database=c:\\somedb.fdb;DataSource=SOMESERVERNAME;Port=SOMEPORT;Dialect=3;Charset=ISO8859_1;ServerType=0;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyBasicSupport.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
DB Operation: Open connection | ||
Info: Beginning database upgrade | ||
Info: Checking whether journal table exists.. | ||
DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_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.. | ||
DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'schemaversions' | ||
DB Operation: Dispose command | ||
Info: Creating the "schemaversions" table | ||
DB Operation: Execute non query command: CREATE TABLE "schemaversions" | ||
( | ||
schemaversionsid INTEGER NOT NULL, | ||
scriptname VARCHAR(255) NOT NULL, | ||
applied TIMESTAMP NOT NULL, | ||
CONSTRAINT pk_schemaversions_id PRIMARY KEY (schemaversionsid) | ||
) | ||
DB Operation: Dispose command | ||
Info: The "schemaversions" table has been created | ||
DB Operation: Execute non query command: CREATE SEQUENCE GEN_schemaversionsID | ||
DB Operation: Dispose command | ||
Info: The GEN_schemaversionsID generator has been created | ||
DB Operation: Execute non query command: CREATE TRIGGER BI_schemaversionsID FOR "schemaversions" ACTIVE BEFORE INSERT POSITION 0 AS BEGIN | ||
if (new.schemaversionsid is null or (new.schemaversionsid = 0)) then new.schemaversionsid = gen_id(GEN_schemaversionsID,1); | ||
END; | ||
DB Operation: Dispose command | ||
Info: The BI_schemaversionsID trigger has been created | ||
DB Operation: Execute non query command: script1contents | ||
DB Operation: Dispose command | ||
DB Operation: Create parameter | ||
Info: DB Operation: Add parameter to command: scriptName=Script0001.sql | ||
DB Operation: Create parameter | ||
Info: DB Operation: Add parameter to command: applied=<date> | ||
DB Operation: Execute non query command: insert into "schemaversions" (ScriptName, Applied) values (@scriptName, @applied) | ||
DB Operation: Dispose command | ||
Info: Upgrade successful | ||
DB Operation: Dispose connection |
38 changes: 38 additions & 0 deletions
38
src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyJournalCreationIfNameChanged.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
DB Operation: Open connection | ||
Info: Beginning database upgrade | ||
Info: Checking whether journal table exists.. | ||
DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_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.. | ||
DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'TestSchemaVersions' | ||
DB Operation: Dispose command | ||
Info: Creating the "TestSchemaVersions" table | ||
DB Operation: Execute non query command: CREATE TABLE "TestSchemaVersions" | ||
( | ||
schemaversionsid INTEGER NOT NULL, | ||
scriptname VARCHAR(255) NOT NULL, | ||
applied TIMESTAMP NOT NULL, | ||
CONSTRAINT pk_TestSchemaVersions_id PRIMARY KEY (schemaversionsid) | ||
) | ||
DB Operation: Dispose command | ||
Info: The "TestSchemaVersions" table has been created | ||
DB Operation: Execute non query command: CREATE SEQUENCE GEN_TestSchemaVersionsID | ||
DB Operation: Dispose command | ||
Info: The GEN_TestSchemaVersionsID generator has been created | ||
DB Operation: Execute non query command: CREATE TRIGGER BI_TestSchemaVersionsID FOR "TestSchemaVersions" ACTIVE BEFORE INSERT POSITION 0 AS BEGIN | ||
if (new.schemaversionsid is null or (new.schemaversionsid = 0)) then new.schemaversionsid = gen_id(GEN_TestSchemaVersionsID,1); | ||
END; | ||
DB Operation: Dispose command | ||
Info: The BI_TestSchemaVersionsID trigger has been created | ||
DB Operation: Execute non query command: script1contents | ||
DB Operation: Dispose command | ||
DB Operation: Create parameter | ||
Info: DB Operation: Add parameter to command: scriptName=Script0001.sql | ||
DB Operation: Create parameter | ||
Info: DB Operation: Add parameter to command: applied=<date> | ||
DB Operation: Execute non query command: insert into "TestSchemaVersions" (ScriptName, Applied) values (@scriptName, @applied) | ||
DB Operation: Dispose command | ||
Info: Upgrade successful | ||
DB Operation: Dispose connection |
38 changes: 38 additions & 0 deletions
38
src/Tests/ApprovalFiles/DatabaseSupportTests.VerifyVariableSubstitutions.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
DB Operation: Open connection | ||
Info: Beginning database upgrade | ||
Info: Checking whether journal table exists.. | ||
DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_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.. | ||
DB Operation: Execute scalar command: select 1 from RDB$RELATIONS where RDB$SYSTEM_FLAG = 0 and RDB$RELATION_NAME = 'schemaversions' | ||
DB Operation: Dispose command | ||
Info: Creating the "schemaversions" table | ||
DB Operation: Execute non query command: CREATE TABLE "schemaversions" | ||
( | ||
schemaversionsid INTEGER NOT NULL, | ||
scriptname VARCHAR(255) NOT NULL, | ||
applied TIMESTAMP NOT NULL, | ||
CONSTRAINT pk_schemaversions_id PRIMARY KEY (schemaversionsid) | ||
) | ||
DB Operation: Dispose command | ||
Info: The "schemaversions" table has been created | ||
DB Operation: Execute non query command: CREATE SEQUENCE GEN_schemaversionsID | ||
DB Operation: Dispose command | ||
Info: The GEN_schemaversionsID generator has been created | ||
DB Operation: Execute non query command: CREATE TRIGGER BI_schemaversionsID FOR "schemaversions" ACTIVE BEFORE INSERT POSITION 0 AS BEGIN | ||
if (new.schemaversionsid is null or (new.schemaversionsid = 0)) then new.schemaversionsid = gen_id(GEN_schemaversionsID,1); | ||
END; | ||
DB Operation: Dispose command | ||
Info: The BI_schemaversionsID trigger has been created | ||
DB Operation: Execute non query command: print SubstitutedValue | ||
DB Operation: Dispose command | ||
DB Operation: Create parameter | ||
Info: DB Operation: Add parameter to command: scriptName=Script0001.sql | ||
DB Operation: Create parameter | ||
Info: DB Operation: Add parameter to command: applied=<date> | ||
DB Operation: Execute non query command: insert into "schemaversions" (ScriptName, Applied) values (@scriptName, @applied) | ||
DB Operation: Dispose command | ||
Info: Upgrade successful | ||
DB Operation: Dispose connection |
43 changes: 43 additions & 0 deletions
43
src/Tests/ApprovalFiles/NoPublicApiChanges.Run.DotNet.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[assembly: System.CLSCompliantAttribute(true)] | ||
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] | ||
|
||
public static class FirebirdExtensions | ||
{ | ||
public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(DbUp.Engine.Transactions.IConnectionManager connectionManager) { } | ||
public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { } | ||
public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.Engine.Transactions.IConnectionManager connectionManager) { } | ||
} | ||
namespace DbUp.Firebird | ||
{ | ||
public class FirebirdConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager | ||
{ | ||
public FirebirdConnectionManager(string connectionString) { } | ||
protected override DbUp.Engine.Transactions.AllowedTransactionMode AllowedTransactionModes { get; } | ||
public override System.Collections.Generic.IEnumerable<string> SplitScriptIntoCommands(string scriptContents) { } | ||
} | ||
public class FirebirdObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser | ||
{ | ||
public FirebirdObjectParser() { } | ||
} | ||
public class FirebirdPreprocessor : DbUp.Engine.IScriptPreprocessor | ||
{ | ||
public FirebirdPreprocessor() { } | ||
public string Process(string contents) { } | ||
} | ||
public class FirebirdScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor | ||
{ | ||
public FirebirdScriptExecutor(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManagerFactory, System.Func<DbUp.Engine.Output.IUpgradeLog> log, string schema, System.Func<bool> variablesEnabled, System.Collections.Generic.IEnumerable<DbUp.Engine.IScriptPreprocessor> scriptPreprocessors, System.Func<DbUp.Engine.IJournal> journal) { } | ||
protected override bool UseTheSameTransactionForJournalTableAndScripts { get; } | ||
protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { } | ||
protected override string GetVerifySchemaSql(string schema) { } | ||
} | ||
public class FirebirdTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal | ||
{ | ||
public FirebirdTableJournal(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManager, System.Func<DbUp.Engine.Output.IUpgradeLog> logger, string tableName) { } | ||
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { } | ||
protected override string DoesTableExistSql() { } | ||
protected override string GetInsertJournalEntrySql(string scriptName, string applied) { } | ||
protected override string GetJournalEntriesSql() { } | ||
protected override void OnTableCreated(System.Func<System.Data.IDbCommand> dbCommandFactory) { } | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[assembly: System.CLSCompliantAttribute(true)] | ||
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)] | ||
|
||
public static class FirebirdExtensions | ||
{ | ||
public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(DbUp.Engine.Transactions.IConnectionManager connectionManager) { } | ||
public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { } | ||
public static DbUp.Builder.UpgradeEngineBuilder FirebirdDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.Engine.Transactions.IConnectionManager connectionManager) { } | ||
} | ||
namespace DbUp.Firebird | ||
{ | ||
public class FirebirdConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager | ||
{ | ||
public FirebirdConnectionManager(string connectionString) { } | ||
protected override DbUp.Engine.Transactions.AllowedTransactionMode AllowedTransactionModes { get; } | ||
public override System.Collections.Generic.IEnumerable<string> SplitScriptIntoCommands(string scriptContents) { } | ||
} | ||
public class FirebirdObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser | ||
{ | ||
public FirebirdObjectParser() { } | ||
} | ||
public class FirebirdPreprocessor : DbUp.Engine.IScriptPreprocessor | ||
{ | ||
public FirebirdPreprocessor() { } | ||
public string Process(string contents) { } | ||
} | ||
public class FirebirdScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor | ||
{ | ||
public FirebirdScriptExecutor(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManagerFactory, System.Func<DbUp.Engine.Output.IUpgradeLog> log, string schema, System.Func<bool> variablesEnabled, System.Collections.Generic.IEnumerable<DbUp.Engine.IScriptPreprocessor> scriptPreprocessors, System.Func<DbUp.Engine.IJournal> journal) { } | ||
protected override bool UseTheSameTransactionForJournalTableAndScripts { get; } | ||
protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { } | ||
protected override string GetVerifySchemaSql(string schema) { } | ||
} | ||
public class FirebirdTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal | ||
{ | ||
public FirebirdTableJournal(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManager, System.Func<DbUp.Engine.Output.IUpgradeLog> logger, string tableName) { } | ||
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { } | ||
protected override string DoesTableExistSql() { } | ||
protected override string GetInsertJournalEntrySql(string scriptName, string applied) { } | ||
protected override string GetJournalEntriesSql() { } | ||
protected override void OnTableCreated(System.Func<System.Data.IDbCommand> dbCommandFactory) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#if !NETCORE | ||
using DbUp.Builder; | ||
using DbUp.Firebird; | ||
using DbUp.Tests.Common; | ||
|
||
namespace DbUp.Tests.Providers.Firebird; | ||
|
||
public class DatabaseSupportTests : DatabaseSupportTestsBase | ||
{ | ||
public DatabaseSupportTests() : base() | ||
{ | ||
} | ||
|
||
protected override UpgradeEngineBuilder DeployTo(SupportedDatabases to) | ||
=> to.FirebirdDatabase(""); | ||
|
||
protected override UpgradeEngineBuilder AddCustomNamedJournalToBuilder(UpgradeEngineBuilder builder, string schema, string tableName) | ||
=> builder.JournalTo( | ||
(connectionManagerFactory, logFactory) | ||
=> new FirebirdTableJournal(connectionManagerFactory, logFactory, tableName) | ||
); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#if !NETCORE | ||
using DbUp.Tests.Common; | ||
|
||
namespace DbUp.Tests.Providers.Firebird; | ||
|
||
public class NoPublicApiChanges : NoPublicApiChangesBase | ||
{ | ||
public NoPublicApiChanges() | ||
: base(typeof(FirebirdExtensions).Assembly) | ||
{ | ||
} | ||
} | ||
#endif |
Oops, something went wrong.