Skip to content

Commit

Permalink
Fix for #3514
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgreenmix authored and jeremydmiller committed Oct 25, 2024
1 parent c9a79c4 commit 9fdfc7d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Marten/Events/Operations/EstablishTombstoneStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ internal class EstablishTombstoneStream: IStorageOperation
public EstablishTombstoneStream(EventGraph events, string sessionTenantId)
{
_sessionTenantId = sessionTenantId;
var pkFields = events.TenancyStyle == TenancyStyle.Conjoined
? "id, tenant_id"
: "id";
var pkFields = "id";
if (events.TenancyStyle == TenancyStyle.Conjoined)
{
pkFields += ", tenant_id";
}
if (events.UseArchivedStreamPartitioning)
{
pkFields += ", is_archived";
}

_sql = $@"
insert into {events.DatabaseSchemaName}.mt_streams (id, tenant_id, version)
values (?, ?, 0)
insert into {events.DatabaseSchemaName}.mt_streams (id, tenant_id, version, is_archived)
values (?, ?, 0, false)
ON CONFLICT ({pkFields})
DO NOTHING
";
Expand Down

0 comments on commit 9fdfc7d

Please sign in to comment.