This commit is contained in:
@@ -422,7 +422,7 @@ namespace AyaNova
|
||||
if (ServerBootConfig.AYANOVA_PERMANENTLY_ERASE_DATABASE)
|
||||
{
|
||||
_newLog.LogWarning("BOOT: AYANOVA_PERMANENTLY_ERASE_DATABASE is true, dropping and recreating database");
|
||||
Util.DbUtil.DropAndRecreateDb(_newLog);
|
||||
Util.DbUtil.DropAndRecreateDbAsync(_newLog);
|
||||
AySchema.CheckAndUpdate(dbContext, _newLog);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace AyaNova.Util
|
||||
// This is the NUCLEAR option and
|
||||
// completely ditches the DB and all user uploaded files
|
||||
//
|
||||
internal static void DropAndRecreateDb(ILogger _log)
|
||||
internal static async Task DropAndRecreateDbAsync(ILogger _log)
|
||||
{
|
||||
_log.LogInformation("Dropping and recreating Database \"{0}\"", _dbName);
|
||||
|
||||
@@ -227,20 +227,20 @@ namespace AyaNova.Util
|
||||
|
||||
using (var conn = new Npgsql.NpgsqlConnection(AdminConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
await conn.OpenAsync();
|
||||
|
||||
// Create the database desired
|
||||
using (var cmd = new Npgsql.NpgsqlCommand())
|
||||
{
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = "DROP DATABASE \"" + _dbName + "\";";
|
||||
cmd.ExecuteNonQuery();
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = "CREATE DATABASE \"" + _dbName + "\";";
|
||||
cmd.ExecuteNonQuery();
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
_log.LogInformation("Database re-created successfully!");
|
||||
}
|
||||
conn.Close();
|
||||
await conn.CloseAsync();
|
||||
}
|
||||
|
||||
//final cleanup step is to erase user uploaded files
|
||||
@@ -286,17 +286,17 @@ namespace AyaNova.Util
|
||||
|
||||
//REMOVE ALL DATA with few exceptions of manager user, license, schema tables
|
||||
//and job logs because this is called by job code
|
||||
EraseTableAsync("afileattachment", conn);
|
||||
EraseTableAsync("awidget", conn);
|
||||
EraseTableAsync("aevent", conn);
|
||||
EraseTableAsync("adatalistfilter", conn);
|
||||
EraseTableAsync("adatalisttemplate", conn);
|
||||
EraseTableAsync("aformcustom", conn);
|
||||
EraseTableAsync("asearchkey", conn);
|
||||
EraseTableAsync("asearchdictionary", conn);
|
||||
EraseTableAsync("atag", conn);
|
||||
await EraseTableAsync("afileattachment", conn);
|
||||
await EraseTableAsync("awidget", conn);
|
||||
await EraseTableAsync("aevent", conn);
|
||||
await EraseTableAsync("adatalistfilter", conn);
|
||||
await EraseTableAsync("adatalisttemplate", conn);
|
||||
await EraseTableAsync("aformcustom", conn);
|
||||
await EraseTableAsync("asearchkey", conn);
|
||||
await EraseTableAsync("asearchdictionary", conn);
|
||||
await EraseTableAsync("atag", conn);
|
||||
|
||||
conn.Close();
|
||||
await conn.CloseAsync();
|
||||
}
|
||||
|
||||
//If we got here then it's safe to erase the attachment files
|
||||
|
||||
Reference in New Issue
Block a user