Skip to content

Commit

Permalink
Upgrading Weasel to fix an issue with managed list partitions when no…
Browse files Browse the repository at this point in the history
…t using the string value as the partition suffix
  • Loading branch information
jeremydmiller committed Sep 26, 2024
1 parent daa07ed commit aaead6f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Marten/Marten.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<PackageReference Include="Polly.Core" Version="8.3.1" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="Weasel.Postgresql" Version="7.11.1" />
<PackageReference Include="Weasel.Postgresql" Version="7.11.2" />
</ItemGroup>

<!--SourceLink specific settings-->
Expand Down
38 changes: 38 additions & 0 deletions src/MultiTenancyTests/marten_managed_tenant_id_partitioning.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -73,6 +74,43 @@ await theStore

}

[Fact]
public async Task can_build_storage_with_dynamic_tenants_by_variable_tenant_and_suffix_mappings()
{
StoreOptions(opts =>
{
opts.Policies.AllDocumentsAreMultiTenanted();
opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants");
opts.Schema.For<Target>();
opts.Schema.For<User>();
}, true);

var tenantId1 = Guid.NewGuid().ToString();
var tenantId2 = Guid.NewGuid().ToString();
var tenantId3 = Guid.NewGuid().ToString();

var names = new Dictionary<string, string>
{
{ tenantId1, "a1" }, { tenantId2, "a2" }, { tenantId3, "a3" }
};

await theStore
.Advanced
// This is ensuring that there are tenant id partitions for all multi-tenanted documents
// with the named tenant ids
.AddMartenManagedTenantsAsync(CancellationToken.None, names);

await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync();

var targetTable = await theStore.Storage.Database.ExistingTableFor(typeof(Target));
assertTableHasTenantPartitions(targetTable, "a1", "a2", "a3");

var userTable = await theStore.Storage.Database.ExistingTableFor(typeof(User));
assertTableHasTenantPartitions(userTable, "a1", "a2", "a3");

}

[Fact]
public async Task can_build_then_add_additive_partitions_later()
{
Expand Down

0 comments on commit aaead6f

Please sign in to comment.