From 50c969b4cecfd9d378defda3986e839adc734faf Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 26 Oct 2022 18:35:44 +0000 Subject: [PATCH] case 4221 --- .vscode/launch.json | 4 +++- devdocs/todo.txt | 2 +- server/AyaNova/util/DbUtil.cs | 23 +++++++++++++++-------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0f993a29..4f5b3cca 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,6 +53,7 @@ // }, "env": { + //############ PERPETUAL BLOCK ###################### // "ASPNETCORE_ENVIRONMENT": "Development", "AYANOVA_JWT_SECRET": "1111111MyRandom32CharacterSecret", "AYANOVA_LOG_LEVEL": "Info", @@ -106,6 +107,7 @@ }, "env": { + //############ SUBSCRIPTION MODE BLOCK ###################### // "ASPNETCORE_ENVIRONMENT": "Development", //"AYANOVA_REPORT_RENDERING_TIMEOUT":"1", "AYANOVA_JWT_SECRET": "1111111MyRandom32CharacterSecret", @@ -117,7 +119,7 @@ "AYANOVA_DATA_PATH": "c:\\temp\\ravendata", "AYANOVA_USE_URLS": "http://*:7575;", //"AYANOVA_PERMANENTLY_ERASE_DATABASE":"true", - //"AYANOVA_REMOVE_LICENSE_FROM_DB":"true", + // "AYANOVA_REMOVE_LICENSE_FROM_DB":"true", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" }, "sourceFileMap": { diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 23f01471..92d4b053 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -14,7 +14,7 @@ todo: Money money money...MONEY - Can do todo-reorg and move to cases while awaiting responses for the above - +todo: case 4221 eval erase issue todo: add guided tours case 4212 todo: postgres 15 case 4214 diff --git a/server/AyaNova/util/DbUtil.cs b/server/AyaNova/util/DbUtil.cs index 00f3fdfb..8bc8008a 100644 --- a/server/AyaNova/util/DbUtil.cs +++ b/server/AyaNova/util/DbUtil.cs @@ -397,7 +397,14 @@ namespace AyaNova.Util // and by v8 migrate and by license controller when erasing db internal static async Task EmptyBizDataFromDatabaseForSeedingOrImportingAsync(ILogger _log, Guid jobIdToKeep, bool isMigrate = false) { - + //case 4221 + //erase plan to use truncate table instead of slower delete method + //- truncate table cascade deletes which removes all user accounts including superuser + //- duplicate the auser and auseroption tables to a temporary table to preserve them + //- do the full truncate + //- select the superuser account back to the auser and useroptions + //- discover where else this needs to be done + //- $profit bool forSeeding = jobIdToKeep != Guid.Empty; _log.LogInformation("Erasing Database \"{0}\"", _dbName); @@ -686,16 +693,16 @@ namespace AyaNova.Util cmd.Connection = conn; //Boo! Can't do this becuase it will fail if there is a foreign key which nearly all tables have unless cascade option is used //but then cascade causes things to delete in any referenced table - // cmd.CommandText = "TRUNCATE \"" + sTable + "\" RESTART IDENTITY;"; + cmd.CommandText = "TRUNCATE \"" + sTable + "\" RESTART IDENTITY CASCADE;"; - cmd.CommandText = $"delete from {sTable};"; + //// cmd.CommandText = $"delete from {sTable};"; await cmd.ExecuteNonQueryAsync(); - if (!tableHasNoSequence) - { - cmd.CommandText = $"ALTER SEQUENCE {sTable}_id_seq RESTART WITH 1;"; - await cmd.ExecuteNonQueryAsync(); + // // if (!tableHasNoSequence) + // // { + // // cmd.CommandText = $"ALTER SEQUENCE {sTable}_id_seq RESTART WITH 1;"; + // // await cmd.ExecuteNonQueryAsync(); - } + // // } } }