30 lines
849 B
C#
30 lines
849 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
public static class GatewayDbResetHelper
|
|
{
|
|
public static async Task ResetAsync(GatewayDbContext db)
|
|
{
|
|
for (var attempt = 0; ; attempt++)
|
|
{
|
|
try
|
|
{
|
|
await db.Database.ExecuteSqlRawAsync(@"
|
|
DELETE FROM buffered_sync_items;
|
|
DELETE FROM sync_outbox;
|
|
DELETE FROM clinical_alerts;
|
|
DELETE FROM observations;
|
|
DELETE FROM encounters;
|
|
DELETE FROM patients;
|
|
DELETE FROM alert_thresholds;
|
|
DELETE FROM gateway_sync_state;
|
|
");
|
|
return;
|
|
}
|
|
catch when (attempt < 5)
|
|
{
|
|
await Task.Delay(1000);
|
|
}
|
|
}
|
|
}
|
|
}
|