Skip to content

Commit

Permalink
Merge pull request #6 from dbuenor/dbueno/add-logging-to-saga-ensure-…
Browse files Browse the repository at this point in the history
…tables-created

Added more log to ensure-saga-tables-created method
  • Loading branch information
pruiz committed Feb 16, 2017
2 parents bb642c5 + 2fefb7b commit f1c79c2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Rebus.AdoNet/AdoNetSagaPersister.cs
Expand Up @@ -82,11 +82,20 @@ public AdoNetSagaPersisterFluentConfigurer EnsureTablesAreCreated()
var tableNames = scope.GetTableNames();

// bail out if there's already a table in the database with one of the names
if (tableNames.Contains(sagaTableName, StringComparer.InvariantCultureIgnoreCase)
|| tableNames.Contains(sagaIndexTableName, StringComparer.OrdinalIgnoreCase))
{
return this;
}
var sagaTableIsAlreadyCreated = tableNames.Contains(sagaTableName, StringComparer.InvariantCultureIgnoreCase);
var sagaIndexTableIsAlreadyCreated = tableNames.Contains(sagaIndexTableName, StringComparer.OrdinalIgnoreCase);

if (sagaTableIsAlreadyCreated && sagaIndexTableIsAlreadyCreated)
{
return this;
}

if (sagaTableIsAlreadyCreated || sagaIndexTableIsAlreadyCreated)
{
// if saga index is created, then saga table is not created and vice versa
throw new ApplicationException(string.Format("Table '{0}' do not exist - you have to create it manually",
sagaIndexTableIsAlreadyCreated ? sagaTableName : sagaIndexTableName));
}

log.Info("Tables '{0}' and '{1}' do not exist - they will be created now", sagaTableName, sagaIndexTableName);

Expand Down

0 comments on commit f1c79c2

Please sign in to comment.