diff --git a/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs b/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs index e2adc53..cd3f4e0 100644 --- a/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs +++ b/Rebus.PostgreSql/PostgreSql/Sagas/PostgreSqlSagaStorage.cs @@ -3,6 +3,7 @@ using System.Linq; // ReSharper disable once RedundantUsingDirective (because .NET Core) using System.Reflection; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Npgsql; using NpgsqlTypes; @@ -413,7 +414,15 @@ async Task CreateIndex(ISagaData sagaData, PostgresConnection connection, IEnume string GetSagaTypeName(Type sagaDataType) { - return sagaDataType.FullName; + return _removeVersionFromTypeFullName(); + + // Rebus cannot find existing saga when the version changes, which breaks a long-running saga with deployments during the saga lifetime. + string _removeVersionFromTypeFullName() + { + return sagaDataType.FullName != null + ? Regex.Replace(sagaDataType.FullName, @"Version=\d+\.\d+\.\d+\.\d+, ", "") + : null; + } } static List> GetPropertiesToIndex(ISagaData sagaData, IEnumerable correlationProperties)