Skip to content

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

Use PATCH instead for POST for upsert backup setting

天舟cbf39536d6a3
diff --git a/api/backup.go b/api/backup.go
index 8158d5f3a7..dd29b22bf8 100644
--- a/api/backup.go
+++ b/api/backup.go
@@ -179,7 +179,8 @@ type BackupSettingFind struct {
// Domain specific fields
}
-// BackupSettingUpsert is the message to set a backup settings.
+// BackupSettingUpsert is the message to upsert a backup settings.
+// NOTE: We use PATCH for Upsert, this is inspired by https://google.aip.dev/134#patch-and-put
type BackupSettingUpsert struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
diff --git a/frontend/src/store/modules/backup.ts b/frontend/src/store/modules/backup.ts
index 357a6933f2..a9c374fe0f 100644
--- a/frontend/src/store/modules/backup.ts
+++ b/frontend/src/store/modules/backup.ts
@@ -163,7 +163,7 @@ const actions = {
{ newBackupSetting }: { newBackupSetting: BackupSettingUpsert }
) {
const data = (
- await axios.post(
+ await axios.patch(
`/api/database/${newBackupSetting.databaseId}/backupsetting`,
{
data: {
diff --git a/server/acl_casbin_policy_dba.csv b/server/acl_casbin_policy_dba.csv
index 3c59c158d9..5c6ae59c5f 100644
--- a/server/acl_casbin_policy_dba.csv
+++ b/server/acl_casbin_policy_dba.csv
@@ -40,7 +40,7 @@ p, DBA, /database/{id}/backup, GET
p, DBA, /database/{id}/backup, POST
p, DBA, /database/{id}/restore, POST
p, DBA, /database/{id}/backupsetting, GET
-p, DBA, /database/{id}/backupsetting, POST
+p, DBA, /database/{id}/backupsetting, PATCH
p, DBA, /issue, POST
p, DBA, /issue, GET
p, DBA, /issue/{id}, GET
diff --git a/server/acl_casbin_policy_developer.csv b/server/acl_casbin_policy_developer.csv
index 19ab93992c..d88e6c40e3 100644
--- a/server/acl_casbin_policy_developer.csv
+++ b/server/acl_casbin_policy_developer.csv
@@ -36,7 +36,7 @@ p, DEVELOPER, /database/{id}/backup, GET
p, DEVELOPER, /database/{id}/backup, POST
p, DEVELOPER, /database/{id}/restore, POST
p, DEVELOPER, /database/{id}/backupsetting, GET
-p, DEVELOPER, /database/{id}/backupsetting, POST
+p, DEVELOPER, /database/{id}/backupsetting, PATCH
p, DEVELOPER, /issue, POST
p, DEVELOPER, /issue, GET
p, DEVELOPER, /issue/{id}, GET
diff --git a/server/acl_casbin_policy_owner.csv b/server/acl_casbin_policy_owner.csv
index e4ce19386e..d09e4299a9 100644
--- a/server/acl_casbin_policy_owner.csv
+++ b/server/acl_casbin_policy_owner.csv
@@ -44,7 +44,7 @@ p, OWNER, /database/{id}/backup, GET
p, OWNER, /database/{id}/backup, POST
p, OWNER, /database/{id}/restore, POST
p, OWNER, /database/{id}/backupsetting, GET
-p, OWNER, /database/{id}/backupsetting, POST
+p, OWNER, /database/{id}/backupsetting, PATCH
p, OWNER, /issue, POST
p, OWNER, /issue, GET
p, OWNER, /issue/{id}, GET
diff --git a/server/database.go b/server/database.go
index 06bd897f2a..3b88b8eb51 100644
--- a/server/database.go
+++ b/server/database.go
@@ -467,7 +467,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {
return nil
})
- g.POST("/database/:id/backupsetting", func(c echo.Context) error {
+ g.PATCH("/database/:id/backupsetting", func(c echo.Context) error {
id, err := strconv.Atoi(c.Param("id"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)