MM-36990: Use upsert for system key update (#18037)

* MM-36990: Use upsert for system key update

We make the app migration idempotent by using DB native upsert.

https://mattermost.atlassian.net/browse/MM-36990

```release-note
NONE
```

* Fix SaveOrUpdateWithWarnMetricHandling too

```release-note
NONE
```

* Update store/sqlstore/system_store.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Этот коммит содержится в:
Agniva De Sarker
2021-08-03 14:23:47 +05:30
коммит произвёл GitHub
родитель 404b7eeade
Коммит 249a0b9870
3 изменённых файлов: 35 добавлений и 18 удалений

Просмотреть файл

@@ -183,7 +183,7 @@ func (s *Server) doPermissionsMigration(key string, migrationMap permissionsMap,
}
}
if err := s.Store.System().Save(&model.System{Name: key, Value: "true"}); err != nil {
if err := s.Store.System().SaveOrUpdate(&model.System{Name: key, Value: "true"}); err != nil {
return model.NewAppError("doPermissionsMigration", "app.system.save.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return nil