Closed wuzhican closed 11 months ago
@tangyang9464 @JalinWang @imp2002
@wuzhican can you make a PR to fix it?
According to my test, adding Restart Identity after the truncate table in PostgreSQL can reset the sequence. However, other databases may not support the Restart Identity syntax and the Restart Identity does not take effect for the sequences in the table created manually by the user. More tests are needed before repairing. Another way to fix is to modify truncate to delete, which will reset the sequence, but this will be slower than truncate. Which repair method are you more inclined to?
@wuzhican delete is good
please check my PR
After my retest, truncate resets the id in mysql and mssql. Postgres also resets the ID when it adds the restart identity. However, delete does not reset the ID for all three databases. As for the other databases, I did not test them.
I use PostgreSQL as the database, and when I SavePolicy, the adapter uses truncate to empty the policy table and then insert records. However, in practice, truncate does not reset the id count value after emptying the table, which causes the id to increment itself whenever the policy is saved as the program runs, and eventually overflows. Haven't had a problem with this issue yet, but OCD asked me if it's necessary to fix the problem with this place.