Skip to content

Commit

Permalink
Removed DropUnderlyingTable methods from stores
Browse files Browse the repository at this point in the history
  • Loading branch information
stidsborg committed Sep 15, 2024
1 parent cb6c843 commit f2a12c0
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ private async Task<IArbitrator> CreateArbitrator([CallerMemberName] string membe
{
var underlyingRegister = new MySqlUnderlyingRegister(Sql.ConnectionString);
var arbitrator = new Arbitrator(underlyingRegister);
await underlyingRegister.DropUnderlyingTable();
await underlyingRegister.Initialize();
await underlyingRegister.Initialize();
return arbitrator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ private async Task<IMonitor> CreateAndInitializeMonitor([CallerMemberName] strin
{
var underlyingRegister = new MySqlUnderlyingRegister(Sql.ConnectionString);
var monitor = new Monitor(underlyingRegister);
await underlyingRegister.DropUnderlyingTable();
await underlyingRegister.Initialize();
await underlyingRegister.Initialize();
return monitor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace Cleipnir.ResilientFunctions.MySQL.Tests.UtilTests;
[TestClass]
public class RegisterTests : Cleipnir.ResilientFunctions.Tests.TestTemplates.UtilsTests.RegisterTests
{
private readonly SyncedCounter _syncedCounter = new();

[TestMethod]
public override Task SetValueWithNoExistingValueSucceeds()
=> SetValueWithNoExistingValueSucceeds(CreateAndInitializeRegister());
Expand Down Expand Up @@ -60,9 +58,7 @@ public override Task DeleteFailsWhenNonExpectedValueForExistingRegister()

private async Task<IRegister> CreateAndInitializeRegister([CallerMemberName] string memberName = "")
{
var count = _syncedCounter.Increment();
var underlyingRegister = new MySqlUnderlyingRegister(Sql.ConnectionString);
await underlyingRegister.DropUnderlyingTable();
await underlyingRegister.Initialize();
return new Register(underlyingRegister);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ PRIMARY KEY (type, instance, position)
await command.ExecuteNonQueryAsync();
}

private string? _dropUnderlyingTableSql;
public async Task DropUnderlyingTable()
{
await using var conn = await DatabaseHelper.CreateOpenConnection(_connectionString);
_dropUnderlyingTableSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}_messages";
await using var command = new MySqlCommand(_dropUnderlyingTableSql, conn);
await command.ExecuteNonQueryAsync();
}

private string? _truncateTableSql;
public async Task TruncateTable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,4 @@ public async Task<IEnumerable<StoredTimeout>> GetTimeouts(FlowId flowId)
}

private Task<MySqlConnection> CreateConnection() => DatabaseHelper.CreateOpenConnection(_connectionString);

private string? _dropUnderlyingTable;
public async Task DropUnderlyingTable()
{
await using var conn = await DatabaseHelper.CreateOpenConnection(_connectionString);
_dropUnderlyingTable ??= $"DROP TABLE IF EXISTS {_tablePrefix}_timeouts";
await using var command = new MySqlCommand(_dropUnderlyingTable, conn);
await command.ExecuteNonQueryAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,7 @@ SELECT COUNT(*)
var count = (long) (await command.ExecuteScalarAsync() ?? 0);
return count > 0;
}

private string? _dropUnderlyingTableSql;
public async Task DropUnderlyingTable()
{
await using var conn = await DatabaseHelper.CreateOpenConnection(_connectionString);
_dropUnderlyingTableSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}_register";

await using var command = new MySqlCommand(_dropUnderlyingTableSql, conn);
await command.ExecuteNonQueryAsync();
}


private string? _truncateTableSql;
public async Task TruncateTable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ PRIMARY KEY (FlowType, FlowInstance, Position)
} catch (SqlException exception) when (exception.Number == 2714) {}
}

private string? _dropUnderlyingTableSql;
public async Task DropUnderlyingTable()
{
await using var conn = await CreateConnection();
_dropUnderlyingTableSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}_Messages;";
var command = new SqlCommand(_dropUnderlyingTableSql, conn);
await command.ExecuteNonQueryAsync();
}

private string? _truncateTableSql;
public async Task TruncateTable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ public async Task Truncate()
await command.ExecuteNonQueryAsync();
}

private string? _dropUnderlyingTableSql;
public async Task DropUnderlyingTable()
{
await using var conn = await CreateConnection();
_dropUnderlyingTableSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}_Timeouts;";
var command = new SqlCommand(_dropUnderlyingTableSql, conn);
await command.ExecuteNonQueryAsync();
}

private string? _upsertTimeoutSql;
public async Task UpsertTimeout(StoredTimeout storedTimeout, bool overwrite)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ PRIMARY KEY (RegisterType, [Group], Name)
}
}

private string? _dropUnderlyingTableSql;
public async Task DropUnderlyingTable()
{
await using var conn = new SqlConnection(_connectionString);
await conn.OpenAsync();

_dropUnderlyingTableSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}_Register";
await using var command = new SqlCommand(_dropUnderlyingTableSql, conn);
await command.ExecuteNonQueryAsync();
}

private string? _setIfEmptySql;
public async Task<bool> SetIfEmpty(RegisterType registerType, string group, string name, string value)
{
Expand Down

0 comments on commit f2a12c0

Please sign in to comment.