using System;
using System.Collections.Generic;
using DbUp.Engine.Output;
using DbUp.Engine.Transactions;
namespace DBOps.Postgresql
{
public class PostgresqlScriptExecutor: DbUp.Postgresql.PostgresqlScriptExecutor
{
///
/// Initializes an instance of the class.
///
///
/// The logging mechanism.
/// The schema that contains the table.
/// Function that returns true if variables should be replaced, false otherwise.
/// Script Preprocessors in addition to variable substitution
/// Database journal
public PostgresqlScriptExecutor(Func connectionManagerFactory, Func log, string schema, Func variablesEnabled,
IEnumerable scriptPreprocessors, Func journalFactory)
: base(connectionManagerFactory, log, schema, variablesEnabled, scriptPreprocessors, journalFactory)
{
}
protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, Action executeCommand)
{
SqlScript s = (SqlScript)script;
var stopWatch = System.Diagnostics.Stopwatch.StartNew();
try
{
base.ExecuteCommandsWithinExceptionHandler(index, s, executeCommand);
}
catch
{
throw;
}
finally
{
stopWatch.Stop();
s.SetExecutionTime(stopWatch.ElapsedMilliseconds);
}
}
}
}