-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/app/Edelstein.Application.Server/Commands/DatabaseDeleteCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Threading.Tasks; | ||
using Edelstein.Common.Database; | ||
using Microsoft.EntityFrameworkCore; | ||
using Spectre.Console; | ||
using Spectre.Console.Cli; | ||
|
||
namespace Edelstein.Application.Server.Commands; | ||
|
||
public class DatabaseDeleteCommand( | ||
IDbContextFactory<GameDbContext> factory | ||
) : AsyncCommand<DatabaseDeleteCommand.Settings> | ||
{ | ||
public class Settings : CommandSettings; | ||
|
||
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings) | ||
{ | ||
await using var db = await factory.CreateDbContextAsync(); | ||
|
||
await db.Database.EnsureDeletedAsync(); | ||
AnsiConsole.WriteLine("Database deleted"); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters