I get a primary key violation when I db.Create an item that has been soft deleted. Alternatively, when I update the soft-deleted item with a DeletedAt value that indicates that it shouldn't be deleted, maybe that should undelete it. As it stands, neither of these works.
https://github.com/jinzhu/gorm#soft-delete
Are you using Unscoped
I understand you addressed the Update case here but creation is still an issue. If you Create a soft-deleted record it will fail with a primary key violation error.
Is here a way to solve the problem?
@jinzhu
http://gorm.io/docs/delete.html#Delete-record-permanently
http://gorm.io/docs/delete.html#Delete-record-permanently
@jinzhu
Thanks for Jinzhu's reply. Does it have another way to INSERT previous-soft-deleted data in replace with INSERT the data before delete record permanently?
My purpose is to keep all columns of the particular deleted data, and when do next INSERT action, just replace some columns need to be updated but primary key, of course let deleted_at to be NULL.
If I do the hard-delete action before CREATE action, I can't get the column info. before I delete the data. (p.s Of course I can use some tricky way like query the data before hard delete to resume the column info. lol)
Most helpful comment
I understand you addressed the
Updatecase here but creation is still an issue. If youCreatea soft-deleted record it will fail with a primary key violation error.