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

* 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
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-03-08 18:13:37 +03:00
коммит произвёл GitHub
родитель 05503440a6
Коммит 645fee3fe3
37 изменённых файлов: 379 добавлений и 46 удалений

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

@@ -68,6 +68,7 @@ func TestMfaRequired(t *testing.T) {
mockStore.On("User").Return(&mockUserStore)
mockStore.On("Post").Return(&mockPostStore)
mockStore.On("System").Return(&mockSystemStore)
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.Srv().SetLicense(model.NewTestLicense("mfa"))

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

@@ -79,6 +79,7 @@ func TestHandlerServeHTTPSecureTransport(t *testing.T) {
mockStore.On("User").Return(&mockUserStore)
mockStore.On("Post").Return(&mockPostStore)
mockStore.On("System").Return(&mockSystemStore)
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.UpdateConfig(func(config *model.Config) {
*config.ServiceSettings.TLSStrictTransport = true
@@ -321,6 +322,7 @@ func TestHandlerServeCSPHeader(t *testing.T) {
mockStore.On("User").Return(&mockUserStore)
mockStore.On("Post").Return(&mockPostStore)
mockStore.On("System").Return(&mockSystemStore)
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.SiteURL = *cfg.ServiceSettings.SiteURL + "/subpath"
@@ -641,6 +643,7 @@ func TestCheckCSRFToken(t *testing.T) {
mockStore.On("User").Return(&mockUserStore)
mockStore.On("Post").Return(&mockPostStore)
mockStore.On("System").Return(&mockSystemStore)
mockStore.On("GetDBSchemaVersion").Return(1, nil)
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ExperimentalStrictCSRFEnforcement = true