Skip to content

[refactor] improve the gorm transaction that covers flag snapshot in crud logic #355

@zhouzhuojie

Description

@zhouzhuojie

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions