diff --git a/src/Marten/StoreOptions.cs b/src/Marten/StoreOptions.cs index 57cd427532..621c48a500 100644 --- a/src/Marten/StoreOptions.cs +++ b/src/Marten/StoreOptions.cs @@ -469,7 +469,8 @@ public void Connection(string connectionString) { var builder = new NpgsqlConnectionStringBuilder(connectionString); - if (builder.CommandTimeout > 0) CommandTimeout = builder.CommandTimeout; + if (builder.CommandTimeout > 0) + CommandTimeout = builder.CommandTimeout; } catch (Exception) { @@ -619,12 +620,14 @@ internal void ApplyConfiguration() Schema.For().DatabaseSchemaName(Events.DatabaseSchemaName).SingleTenanted(); - foreach (var mapping in Storage.AllDocumentMappings) mapping.CompileAndValidate(); + foreach (var mapping in Storage.AllDocumentMappings) + mapping.CompileAndValidate(); } internal void applyPolicies(DocumentMapping mapping) { - foreach (var policy in _policies) policy.Apply(mapping); + foreach (var policy in _policies) + policy.Apply(mapping); } internal void applyPostPolicies(DocumentMapping mapping) @@ -789,20 +792,28 @@ public PoliciesExpression AllDocumentsAreMultiTenanted() { return ForAllDocuments(mapping => { - if (mapping.DocumentType.HasAttribute()) return; - if (mapping.DocumentType == typeof(DeadLetterEvent)) return; + if (mapping.DocumentType.HasAttribute()) + return; + if (mapping.DocumentType == typeof(DeadLetterEvent)) + return; mapping.TenancyStyle = TenancyStyle.Conjoined; }); } + //TODO -- V9 change default PrimaryKeyTenancyOrdering to TenantId_Then_Id /// /// Unless explicitly marked otherwise, all documents should /// use conjoined multi-tenancy and opt into using user defined - /// PostgreSQL table partitioning + /// PostgreSQL table partitioning. /// /// Customize the table partitioning on the tenant id /// - [Obsolete("Use overload in stead, default used to be id then tenant_id, so use that if you don't want to rebuild all your indexes")] + /// + /// Uses by default for V7-V8 compatibility. + /// This default will change to in V9. + /// If you want to opt-in to the V9 default behavior now, use the overload that takes a + /// parameter. + /// public PoliciesExpression AllDocumentsAreMultiTenantedWithPartitioning(Action configure) => AllDocumentsAreMultiTenantedWithPartitioning(configure, PrimaryKeyTenancyOrdering.Id_Then_TenantId); @@ -812,17 +823,16 @@ public PoliciesExpression AllDocumentsAreMultiTenantedWithPartitioning(Action /// Customize the table partitioning on the tenant id - /// - /// Id or tenant_id first in the primary key. - /// Default used to be , so use that if you don't want to rebuild all your indexes. - /// Given most query's include the tenant_id, the sane default is probably . + /// Customize the primary key tenancy ordering /// /// public PoliciesExpression AllDocumentsAreMultiTenantedWithPartitioning(Action configure, PrimaryKeyTenancyOrdering primaryKeyTenancyOrdering) => ForAllDocuments(mapping => { - if (mapping.DocumentType == typeof(DeadLetterEvent)) return; - if (mapping.DocumentType.HasAttribute()) return; + if (mapping.DocumentType == typeof(DeadLetterEvent)) + return; + if (mapping.DocumentType.HasAttribute()) + return; mapping.PrimaryKeyTenancyOrdering = primaryKeyTenancyOrdering; @@ -841,7 +851,8 @@ public PoliciesExpression PartitionMultiTenantedDocuments(Action { - if (mapping.TenancyStyle == TenancyStyle.Single) return; + if (mapping.TenancyStyle == TenancyStyle.Single) + return; var expression = new PartitioningExpression(mapping, [TenantIdColumn.Name]); configure(expression);