Skip to content

Commit

Permalink
fix: db op order
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Aug 31, 2022
1 parent c796ece commit 960ccf4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions GZCTF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@
{
var context = serviceScope.ServiceProvider.GetRequiredService<AppDbContext>();

await context.Database.EnsureCreatedAsync();

if (context.Database.IsRelational())
await context.Database.MigrateAsync();

await context.Database.EnsureCreatedAsync();

if (!await context.Notices.AnyAsync())
{
await context.Notices.AddAsync(new()
Expand Down
4 changes: 2 additions & 2 deletions GZCTF/Providers/EntityConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public override void Load()

var context = new AppDbContext(builder.Options);

context.Database.EnsureCreated();

if (context.Database.IsRelational())
context.Database.Migrate();

context.Database.EnsureCreated();

if (context is null || !context.Configs.Any())
{
var configs = DefaultConfigs();
Expand Down

0 comments on commit 960ccf4

Please sign in to comment.