-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
In postgres TRUNCATE TABLE doesn't reset the identity by default.
When running respawn.ResetAsync(conn) this sql is executed:
truncate table <list of tables> cascade;Respawn/Respawn/PostgresDbAdapter.cs
Line 197 in 2ad376d
| builder.AppendLine($"truncate table {string.Join(",", allTables)} cascade;"); |
To make it reset the identity this needs to be executed:
truncate table <list of tables> restart identity cascade;Here's a workaround for anyone else stumbling over this:
// workaround for Respawn not resetting identity
// await _respawner.ResetAsync(connection);
var sql = _respawner.DeleteSql?.Replace("cascade", "restart identity cascade");
var cmd = connection.CreateCommand();
cmd.CommandText = sql;
await cmd.ExecuteNonQueryAsync();Metadata
Metadata
Assignees
Labels
No labels