From df129198891757237fa059939af53699fe60ab91 Mon Sep 17 00:00:00 2001 From: Eric Green Date: Fri, 25 Oct 2024 12:57:42 -0500 Subject: [PATCH] Fix for #3514 --- .../Operations/EstablishTombstoneStream.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Marten/Events/Operations/EstablishTombstoneStream.cs b/src/Marten/Events/Operations/EstablishTombstoneStream.cs index d250fbb3d5..e9936fd028 100644 --- a/src/Marten/Events/Operations/EstablishTombstoneStream.cs +++ b/src/Marten/Events/Operations/EstablishTombstoneStream.cs @@ -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 ";