Mono repo -> Master (#22553)
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
Этот коммит содержится в:
54
server/channels/jobs/migrations/migrations.go
Обычный файл
54
server/channels/jobs/migrations/migrations.go
Обычный файл
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/store"
|
||||
)
|
||||
|
||||
const (
|
||||
MigrationStateUnscheduled = "unscheduled"
|
||||
MigrationStateInProgress = "in_progress"
|
||||
MigrationStateCompleted = "completed"
|
||||
|
||||
JobDataKeyMigration = "migration_key"
|
||||
JobDataKeyMigrationLastDone = "last_done"
|
||||
)
|
||||
|
||||
func MakeMigrationsList() []string {
|
||||
return []string{
|
||||
model.MigrationKeyAdvancedPermissionsPhase2,
|
||||
}
|
||||
}
|
||||
|
||||
func GetMigrationState(migration string, store store.Store) (string, *model.Job, *model.AppError) {
|
||||
if _, err := store.System().GetByName(migration); err == nil {
|
||||
return MigrationStateCompleted, nil, nil
|
||||
}
|
||||
|
||||
jobs, err := store.Job().GetAllByType(model.JobTypeMigrations)
|
||||
if err != nil {
|
||||
return "", nil, model.NewAppError("GetMigrationState", "app.job.get_all.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
for _, job := range jobs {
|
||||
if key, ok := job.Data[JobDataKeyMigration]; ok {
|
||||
if key != migration {
|
||||
continue
|
||||
}
|
||||
|
||||
switch job.Status {
|
||||
case model.JobStatusInProgress, model.JobStatusPending:
|
||||
return MigrationStateInProgress, job, nil
|
||||
default:
|
||||
return MigrationStateUnscheduled, job, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MigrationStateUnscheduled, nil, nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user