case 4221
This commit is contained in:
@@ -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();
|
||||
|
||||
}
|
||||
// // }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user