示例#1
0
 /// <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
 /// <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;
 }
示例#3
0
 /// <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;
 }
示例#4
0
 /// <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;
 }
示例#5
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;
 }
示例#6
0
 /// <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;
 }
 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));
     };
 }