Add RecordState handling for prospects and support soft deletion
Introduced the RecordState property to manage the state of prospects, enabling soft deletion and restoration. Updated related database migrations, UI interactions, and filtering logic to accommodate this addition. Also included automatic database migration at runtime to ensure schema compatibility.
This commit is contained in:
@@ -28,6 +28,31 @@ namespace FoodsharingSiegen.Server
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that all pending database migrations are applied at runtime.
|
||||
/// This method checks for pending migrations in the database context and applies them,
|
||||
/// allowing the application to remain compatible with the latest schema changes.
|
||||
/// </summary>
|
||||
/// <param name="app">An instance of <see cref="WebApplication" /> used to access application services and lifecycle methods.</param>
|
||||
public static void ApplyMigrations(this WebApplication app)
|
||||
{
|
||||
using var scope = app.Services.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<FsContext>();
|
||||
|
||||
// Check and apply pending migrations
|
||||
var pendingMigrations = dbContext.Database.GetPendingMigrations();
|
||||
if (pendingMigrations.Any())
|
||||
{
|
||||
Console.WriteLine("Applying pending migrations...");
|
||||
dbContext.Database.Migrate();
|
||||
Console.WriteLine("Migrations applied successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("No pending migrations found.");
|
||||
}
|
||||
}
|
||||
|
||||
#region Public Method LoadAppSettings
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user