flagr
flagr copied to clipboard
[refactor] improve the gorm transaction that covers flag snapshot in crud logic
Some of the database logic is not wrapped into a transaction in crud.go, for example, https://github.com/checkr/flagr/blob/848bcf07b8ff4f6a4a056794d521c62535b2e3b8/pkg/handler/crud.go#L424
Expected Behavior
Ideally, all the database logic of a request can be wrapped into a transaction to avoid data corruption.
Current Behavior
Possible Solution
Use db.Transaction(func(tx *gorm.DB) error {
https://gorm.io/docs/transactions.html#Transactions