[MM-41576] Add schema version to the client configuration (#19757)
* revamp db version and add applied migrations endpoint * replace old schema version with new * add db version subcommand * add to local api * reflect review comments * log errors * remove setting the version from model.CurrentVersion * fix a test * use different field for schema version * add build hash and current version to the support packet * add tests * update test to use new assets
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
47c44a9b7d
Коммит
b03d87af40
@@ -70,6 +70,7 @@ func (api *API) InitSystem() {
|
||||
api.BaseRoutes.System.Handle("/support_packet", api.APISessionRequired(generateSupportPacket)).Methods("GET")
|
||||
api.BaseRoutes.System.Handle("/onboarding/complete", api.APISessionRequired(getOnboarding)).Methods("GET")
|
||||
api.BaseRoutes.System.Handle("/onboarding/complete", api.APISessionRequired(completeOnboarding)).Methods("POST")
|
||||
api.BaseRoutes.System.Handle("/schema/version", api.APISessionRequired(getAppliedSchemaMigrations)).Methods("GET")
|
||||
}
|
||||
|
||||
func generateSupportPacket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -934,3 +935,28 @@ func completeOnboarding(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.Success()
|
||||
ReturnStatusOK(w)
|
||||
}
|
||||
|
||||
func getAppliedSchemaMigrations(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionManageSystem) {
|
||||
c.Err = model.NewAppError("getAppliedMigrations", "app.system.applied_migrations.not_authorized", nil, "", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("getAppliedSchemaMigrations", audit.Fail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
migrations, appErr := c.App.GetAppliedSchemaMigrations()
|
||||
if appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
|
||||
js, jsonErr := json.Marshal(migrations)
|
||||
if jsonErr != nil {
|
||||
c.Err = model.NewAppError("getAppliedMigrations", "api.marshal_error", nil, jsonErr.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write(js)
|
||||
auditRec.Success()
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user