Revert "[MM-41576] Revamp database schema version (#19586)" (#19746)

* Revert "[MM-41576] Revamp database schema version (#19586)"

This reverts commit 645fee3fe3.

* Revert "MM-42049 - license endpoint not working (#19686)"

This reverts commit 4fe89e5847.
Этот коммит содержится в:
Jesse Hallam
2022-03-08 16:28:28 -04:00
коммит произвёл GitHub
родитель eff39010d8
Коммит a2a78577e9
47 изменённых файлов: 215 добавлений и 475 удалений

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

@@ -577,7 +577,7 @@ func TestGetOldClientConfig(t *testing.T) {
config, _, err := client.GetOldClientConfig("")
require.NoError(t, err)
require.Empty(t, config["Version"], "config not returned correctly")
require.NotEmpty(t, config["Version"], "config not returned correctly")
require.Empty(t, config["GoogleDeveloperKey"], "config should be missing developer key")
})

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

@@ -70,7 +70,6 @@ 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) {
@@ -936,28 +935,3 @@ 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()
}

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

@@ -18,7 +18,6 @@ func (api *API) InitSystemLocal() {
api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(getServerBusyExpires)).Methods("GET")
api.BaseRoutes.APIRoot.Handle("/server_busy", api.APILocal(clearServerBusy)).Methods("DELETE")
api.BaseRoutes.APIRoot.Handle("/integrity", api.APILocal(localCheckIntegrity)).Methods("POST")
api.BaseRoutes.System.Handle("/schema/version", api.APILocal(getAppliedSchemaMigrations)).Methods("GET")
}
func localCheckIntegrity(c *Context, w http.ResponseWriter, r *http.Request) {

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

@@ -909,20 +909,3 @@ func TestCompleteOnboarding(t *testing.T) {
})
}
func TestGetAppliedSchemaMigrations(t *testing.T) {
th := Setup(t)
defer th.TearDown()
t.Run("as a regular user", func(t *testing.T) {
_, resp, err := th.Client.GetAppliedSchemaMigrations()
require.Error(t, err)
CheckForbiddenStatus(t, resp)
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
_, resp, err := c.GetAppliedSchemaMigrations()
require.NoError(t, err)
CheckOKStatus(t, resp)
})
}