Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: support to delete normal status database access control policy (#3836)

rebelicefb70f9e70d5c
diff --git a/store/policy.go b/store/policy.go
index 259aecac3c..cfb24394b9 100644
--- a/store/policy.go
+++ b/store/policy.go
@@ -119,7 +119,7 @@ func (s *Store) DeletePolicy(ctx context.Context, policyDelete *api.PolicyDelete
return &common.Error{Code: common.NotFound, Err: errors.Errorf("failed to found policy with filter %+v, expect 1. ", find)}
}
policyRaw := policyRawList[0]
- if policyRaw.RowStatus != api.Archived {
+ if policyRaw.RowStatus != api.Archived && policyDelete.Type == api.PolicyTypeSQLReview {
return &common.Error{Code: common.Invalid, Err: errors.Errorf("failed to delete policy with PolicyDelete[%+v], expect 'ARCHIVED' row_status", policyDelete)}
}
@@ -546,12 +546,11 @@ func upsertPolicyImpl(ctx context.Context, tx *Tx, upsert *api.PolicyUpsert) (*p
func (*Store) deletePolicyImpl(ctx context.Context, tx *Tx, delete *api.PolicyDelete) error {
if _, err := tx.ExecContext(ctx, `
DELETE FROM policy
- WHERE resource_type = $1 AND resource_id = $2 AND type = $3 AND row_status = $4
+ WHERE resource_type = $1 AND resource_id = $2 AND type = $3
`,
delete.ResourceType,
delete.ResourceID,
delete.Type,
- api.Archived,
); err != nil {
return FormatError(err)
}