Skip to content

Remove partitions by value fix #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 7.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,34 @@ public async Task remove_partitions_at_runtime_smoke_test()
.ShouldBe(new []{"blue", "green", "purple"});
}

[Fact]
public async Task remove_partitions_by_value_at_runtime_smoke_test()
{
var database = new ManagedListDatabase();
var partitions = new Dictionary<string, string> { { "red", "red_suffix" }, { "green", "green_suffix" }, { "blue", "blue_suffix" }, };
await database.Partitions.ResetValues(database, partitions, CancellationToken.None);

await database.ApplyAllConfiguredChangesToDatabaseAsync();

await database.Partitions.AddPartitionToAllTables(database, "purple", "purple_suffix", CancellationToken.None);

await database.Partitions.DropPartitionFromAllTablesForValue(database, NullLogger.Instance, "red", CancellationToken.None);

var tables = await database.FetchExistingTablesAsync();

var teams = tables.Single(x => x.Identifier.Name == "teams");
var partitioning = teams.Partitioning.ShouldBeOfType<ListPartitioning>();
partitioning.HasExistingDefault.ShouldBeFalse();
partitioning.Partitions.Select(x => x.Suffix).OrderBy(x => x)
.ShouldBe(new []{"blue_suffix", "green_suffix", "purple_suffix"});

var players = tables.Single(x => x.Identifier.Name == "players");
partitioning = players.Partitioning.ShouldBeOfType<ListPartitioning>();
partitioning.HasExistingDefault.ShouldBeFalse();
partitioning.Partitions.Select(x => x.Suffix).OrderBy(x => x)
.ShouldBe(new []{"blue_suffix", "green_suffix", "purple_suffix"});
}

[Fact]
public async Task apply_additive_migration_2()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task DropPartitionFromAllTablesForValue(PostgresqlDatabase database

try
{
var suffix = _partitions.Single(x => x.Value == value).Key;
var suffix = _partitions[value];
await DropPartitionFromAllTables(database, logger, [suffix], token).ConfigureAwait(false);
}
catch (InvalidOperationException)
Expand Down