コード例 #1
0
ファイル: SqlServerExtensions.cs プロジェクト: ariesy/DbUp
 /// <summary>
 /// Creates an upgrader for SQL Server databases.
 /// </summary>
 /// <param name="supported">Fluent helper type.</param>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <param name="schema">The SQL schema name to use. Defaults to 'dbo'.</param>
 /// <returns>
 /// A builder for a database upgrader designed for SQL Server databases.
 /// </returns>
 public static UpgradeEngineBuilder SqlDatabase(this SupportedDatabases supported, Func<IDbConnection> connectionFactory, string schema)
 {
     var builder = new UpgradeEngineBuilder();
     builder.Configure(c => c.ConnectionFactory = connectionFactory);
     builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(c.ConnectionFactory, () => c.Log, schema, c.ScriptPreprocessors));
     builder.Configure(c => c.Journal = new SqlTableJournal(c.ConnectionFactory, schema, "SchemaVersions", c.Log));
     return builder;
 }
コード例 #2
0
ファイル: DatabaseUpgrader.cs プロジェクト: mdavid626/triton
 private UpgradeEngineBuilder ConfigureTransactions(UpgradeEngineBuilder builder)
 {
     if (TransactionOption == TransactionOption.Transaction)
         return builder.WithTransaction();
     if (TransactionOption == TransactionOption.TransactionPerScript)
         return builder.WithTransactionPerScript();
     return builder.WithoutTransaction();
 }
コード例 #3
0
ファイル: MySqlExtensions.cs プロジェクト: nagorsky/DbUp
 /// <summary>
 /// Creates an upgrader for MySql databases.
 /// </summary>
 /// <param name="connectionManager">The <see cref="MySqlConnectionManager"/> to be used during a database upgrade.</param>
 /// <returns>
 /// A builder for a database upgrader designed for MySql databases.
 /// </returns>
 public static UpgradeEngineBuilder MySqlDatabase(IConnectionManager connectionManager)
 {
     var builder = new UpgradeEngineBuilder();
     builder.Configure(c => c.ConnectionManager = connectionManager);
     builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(() => c.ConnectionManager, () => c.Log, null, () => c.VariablesEnabled, c.ScriptPreprocessors));
     builder.Configure(c => c.Journal = new MySqlITableJournal(() => c.ConnectionManager, () => c.Log, null, "schemaversions"));
     builder.WithPreprocessor(new MySqlPreprocessor());
     return builder;
 }
コード例 #4
0
ファイル: FirebirdExtensions.cs プロジェクト: sergio/DbUp
 /// <summary>
 /// Creates an upgrader for Firebird databases.
 /// </summary>
 /// <param name="connectionManager">The <see cref="FirebirdConnectionManager"/> to be used during a database upgrade.</param>
 /// <returns>
 /// A builder for a database upgrader designed for Firebird databases.
 /// </returns>
 public static UpgradeEngineBuilder FirebirdDatabase(IConnectionManager connectionManager)
 {
     var builder = new UpgradeEngineBuilder();
     builder.Configure(c => c.ConnectionManager = connectionManager);
     builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(() => c.ConnectionManager, () => c.Log, null, () => false, c.ScriptPreprocessors));
     builder.Configure(c => c.Journal = new FirebirdTableJournal(() => c.ConnectionManager, () => c.Log, "schemaversions"));
     builder.WithPreprocessor(new FirebirdPreprocessor());
     return builder;
 }
コード例 #5
0
ファイル: SqlCeExtensions.cs プロジェクト: PicnicBasket/DbUp
 /// <summary>
 /// Creates an upgrader for SQL CE databases.
 /// </summary>
 /// <param name="supported">Fluent helper type.</param>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <returns>
 /// A builder for a database upgrader designed for SQL Server databases.
 /// </returns>
 public static UpgradeEngineBuilder SqlCeDatabase(this SupportedDatabases supported, Func<SqlCeConnection> connectionFactory)
 {
     var builder = new UpgradeEngineBuilder();
     builder.Configure(c => c.ConnectionFactory = connectionFactory);
     builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(c.ConnectionFactory, () => c.Log, null, () => c.VariablesEnabled, c.ScriptPreprocessors));
     builder.Configure(c => c.Journal = new SqlTableJournal(c.ConnectionFactory, null, "SchemaVersions", c.Log));
     builder.WithPreprocessor(new SqlCePreprocessor());
     return builder;
 }
コード例 #6
0
 /// <summary>
 /// Creates an upgrade for SQLite databases with a given database connection 
 /// </summary>
 /// <param name="supported">Fluent helper type.</param>
 /// <param name="sqliteConnection">Given SQLite database connection object which is used by DbUp upgrade engine</param>
 /// <returns>
 /// A builder for a database upgrader designed for SQLite databases.
 /// </returns>
 public static UpgradeEngineBuilder SQLiteDatabase(this SupportedDatabases supported, SQLiteConnection sqliteConnection)
 {
     var builder = new UpgradeEngineBuilder();
     builder.Configure(c => c.ConnectionManager = new SQLiteConnectionManager(sqliteConnection));
     builder.Configure(c => c.Journal = new SQLiteTableJournal(() => c.ConnectionManager, () => c.Log, "SchemaVersions"));
     builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(() => c.ConnectionManager, () => c.Log, null,
         () => c.VariablesEnabled, c.ScriptPreprocessors));
     builder.WithPreprocessor(new SQLitePreprocessor());
     return builder;
 }
コード例 #7
0
 public void SetUp()
 {
     log = Substitute.For<IUpgradeLog>();
     upgradeResult = null;
     scripts = new List<SqlScript>
     {
         new SqlScript("Script1.sql", "create table Foo (Id int identity)"),
         new SqlScript("Script2.sql", "alter table Foo add column Name varchar(255)"),
         new SqlScript("Script3.sql", "insert into Foo (Name) values ('test')")
     };
     database = new TemporarySQLiteDatabase("IntegrationScenarios");
     upgradeEngineBuilder = DeployChanges.To
         .SQLiteDatabase(database.SharedConnection)
         .WithScripts(new TestScriptProvider(scripts))
         .LogTo(log);
 }
コード例 #8
0
ファイル: SqlServerExtensions.cs プロジェクト: rintje/DbUp
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connectionManager"></param>
 /// <param name="schema"></param>
 /// <returns></returns>
 private static UpgradeEngineBuilder SqlDatabase(IConnectionManager connectionManager, string schema)
 {
     var builder = new UpgradeEngineBuilder();
     builder.Configure(c => c.ConnectionManager = connectionManager);
     builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(() => c.ConnectionManager, () => c.Log, schema, () => c.VariablesEnabled, c.ScriptPreprocessors));
     builder.Configure(c => c.Journal = new SqlTableJournal(() => c.ConnectionManager, () => c.Log, schema, "SchemaVersions"));
     return builder;
 }
コード例 #9
0
 private Action Deploy(Func<SupportedDatabases, UpgradeEngineBuilder> deployTo)
 {
     return () =>
     {
         scripts = new List<SqlScript>();
         recordingConnection = new RecordingDbConnection(false);
         testConnectionFactory = new DelegateConnectionFactory(_ => recordingConnection);
         upgradeEngineBuilder = deployTo(DeployChanges.To)
             .WithScripts(scripts);
         upgradeEngineBuilder
             .Configure(c => ((DatabaseConnectionManager) c.ConnectionManager).OverrideFactoryForTest(testConnectionFactory));
     };
 }
コード例 #10
0
ファイル: TransactionScenarios.cs プロジェクト: nagorsky/DbUp
 private void DbUpSetupToUseSingleTransaction()
 {
     testConnection = new RecordingDbConnection(false);
     upgradeEngineBuilder = DeployChanges.To
         .TestDatabase(testConnection)
         .WithTransaction();
 }
コード例 #11
0
ファイル: DatabaseSupportTests.cs プロジェクト: chouzicz/DbUp
 private void JournalTableNameIsCustomised()
 {
     upgradeEngineBuilder = addCustomNamedJournalToBuilder(upgradeEngineBuilder, "test", "TestSchemaVersions");
 }
コード例 #12
0
ファイル: DatabaseSupportTests.cs プロジェクト: chouzicz/DbUp
        private Action Deploy(Func<SupportedDatabases, UpgradeEngineBuilder> deployTo, Func<UpgradeEngineBuilder, string, string, UpgradeEngineBuilder> addCustomNamedJournal)
        {
            return () =>
            {
                scripts = new List<SqlScript>();
                recordingConnection = new RecordingDbConnection(false);
                testConnectionFactory = new DelegateConnectionFactory(_ => recordingConnection);
                upgradeEngineBuilder = deployTo(DeployChanges.To)
                    .WithScripts(scripts)
                    .OverrideConnectionFactory(testConnectionFactory);

                addCustomNamedJournalToBuilder = addCustomNamedJournal;
            };
        }