Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for error while trying to update DB #324

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BLAZAM/Pages/Install/InstallDatabase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ else
await InvokeAsync(StateHasChanged);
try
{
if (await DbFactory.ApplyDatabaseMigrations(true))
if (await DbFactory.ApplyDatabaseMigrationsAsync(true))
{
Completed = true;
await InvokeAsync(StepCompleted.InvokeAsync);
Expand Down
24 changes: 10 additions & 14 deletions BLAZAMDatabase/Context/AppDatabaseFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,17 @@ public IDatabaseContext CreateDbContext()
: databaseContext;
}

/// <summary>
/// Applies all pending database migrations
/// <para>
/// <paramref name="force"/>: If true, the updates will happen
/// even if the database is seeded. If false, no updates will
/// be applied if seeding has already occurred.
/// </para>
/// </summary>
/// <param name="force">If true, the updates will happen even if the database is seeded. If false, no updates will be applied if seeding has already occurred.</param>
/// <returns></returns>
public async Task<bool> ApplyDatabaseMigrations(bool force = false)
public async Task<bool> ApplyDatabaseMigrationsAsync(bool force = false)
{
return await Task.Run(() => {
return ApplyDatabaseMigrations(force);
});

return await Task.Run(() =>
{
}
public bool ApplyDatabaseMigrations(bool force = false)
{


try
{
using (var context = CreateDbContext())
Expand Down Expand Up @@ -187,7 +183,7 @@ public async Task<bool> ApplyDatabaseMigrations(bool force = false)
Loggers.DatabaseLogger.Error("Database Auto-Update Failed!!!! {@Error}", ex);
throw ex;
}
});



}
Expand Down
12 changes: 11 additions & 1 deletion BLAZAMDatabase/Context/IAppDatabaseFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ namespace BLAZAM.Database.Context
/// </summary>
public interface IAppDatabaseFactory
{
/// <summary>
/// Applies any pending database migrations to the database synchronously
/// </summary>
/// <remarks>
/// You must use true for <paramref name="force"/> if you want to apply migrations to an empty database
/// </remarks>
/// <param name="force">Force the update even if the database is empty and has not been seeded yet</param>
/// <returns></returns>
bool ApplyDatabaseMigrations(bool force = false);

/// <summary>
/// Applies any pending database migrations to the database asynchronously
/// </summary>
Expand All @@ -17,7 +27,7 @@ public interface IAppDatabaseFactory
/// </remarks>
/// <param name="force">Force the update even if the database is empty and has not been seeded yet</param>
/// <returns></returns>
Task<bool> ApplyDatabaseMigrations(bool force = false);
Task<bool> ApplyDatabaseMigrationsAsync(bool force = false);
/// <summary>
/// Creates a new connection to this database
/// </summary>
Expand Down
Loading