Skip to content

Commit 2080d31

Browse files
committed
Remove call to RemoveEmptyTenants on server startup.
1 parent e171bfc commit 2080d31

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

‎ControlR.Web.Server/Program.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using ControlR.Web.Server.Middleware;
66
using ControlR.Web.Server.Startup;
77
using ControlR.Web.ServiceDefaults;
8-
using ControlR.Libraries.Api.Contracts.Constants;
98
using Microsoft.Extensions.FileProviders;
109
using Scalar.AspNetCore;
1110
using System.Reflection;
@@ -129,7 +128,6 @@
129128
await app.ApplyMigrations();
130129
await app.SetAllDevicesOffline();
131130
await app.SetAllUsersOffline();
132-
await app.RemoveEmptyTenants();
133131
}
134132

135133
await app.BootstrapAdminUser();

‎ControlR.Web.Server/Startup/IHostExtensions.cs‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,11 @@ public static async Task BootstrapServerServiceAccount(this IHost host, Cancella
199199
}
200200
}
201201

202-
public static async Task RemoveEmptyTenants(this IHost host)
202+
public static async Task EnsureDatabaseCreated(this IHost host)
203203
{
204204
await using var scope = host.Services.CreateAsyncScope();
205205
await using var context = scope.ServiceProvider.GetRequiredService<AppDb>();
206-
var emptyTenants = await context.Tenants
207-
.Where(x => x.Users!.Count == 0)
208-
.ToListAsync();
209-
210-
if (emptyTenants.Count == 0)
211-
{
212-
return;
213-
}
214-
215-
context.Tenants.RemoveRange(emptyTenants);
216-
await context.SaveChangesAsync();
206+
await context.Database.EnsureCreatedAsync();
217207
}
218208

219209
public static async Task SetAllDevicesOffline(this IHost host)

0 commit comments

Comments
 (0)