I am using DbUp (Documentation) package to maintain and execute scripts on the database. Currently, I am using
var builder = DeployChanges.To
.SqlDatabase(connectionString)
.WithExecutionTimeout(TimeSpan.FromSeconds(300))
.WithTransactionPerScript()
.WithScriptsFromFileSystem(rootPath, new FileSystemScriptOptions { IncludeSubDirectories = true })
I want to rollback all the transactions if any scripts fails while executing a bunch of scripts. Using,
WithTransactionAlwaysRollback()
Transaction rolls back even if the all the scripts execute successfully. I only want to rollback on failure.
Is there another way to solve this problem?
Use
instead of
And here's an implementation of these extension methods: