2019-09-09 22:58:26 +00:00
|
|
|
package migrator
|
|
|
|
|
2019-10-08 03:18:32 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
2019-09-09 22:58:26 +00:00
|
|
|
|
2020-06-25 03:25:51 +00:00
|
|
|
const scheduleScriptExecutionJobType = 1
|
|
|
|
|
2019-09-09 22:58:26 +00:00
|
|
|
func (m *Migrator) updateUsersToDBVersion20() error {
|
2022-04-14 04:25:13 +00:00
|
|
|
migrateLog.Info("- updating user authentication")
|
2020-05-20 05:23:15 +00:00
|
|
|
return m.authorizationService.UpdateUsersAuthorizations()
|
2019-09-09 22:58:26 +00:00
|
|
|
}
|
2019-10-08 00:17:58 +00:00
|
|
|
|
|
|
|
func (m *Migrator) updateSettingsToDBVersion20() error {
|
|
|
|
legacySettings, err := m.settingsService.Settings()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
legacySettings.AllowVolumeBrowserForRegularUsers = false
|
|
|
|
|
|
|
|
return m.settingsService.UpdateSettings(legacySettings)
|
|
|
|
}
|
2019-10-08 03:18:32 +00:00
|
|
|
|
|
|
|
func (m *Migrator) updateSchedulesToDBVersion20() error {
|
2022-04-14 04:25:13 +00:00
|
|
|
migrateLog.Info("- updating schedules")
|
2019-10-08 03:18:32 +00:00
|
|
|
legacySchedules, err := m.scheduleService.Schedules()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, schedule := range legacySchedules {
|
2020-06-25 03:25:51 +00:00
|
|
|
if schedule.JobType == scheduleScriptExecutionJobType {
|
2019-10-08 03:18:32 +00:00
|
|
|
if schedule.CronExpression == "0 0 * * *" {
|
|
|
|
schedule.CronExpression = "0 * * * *"
|
|
|
|
} else if schedule.CronExpression == "0 0 0/2 * *" {
|
|
|
|
schedule.CronExpression = "0 */2 * * *"
|
|
|
|
} else if schedule.CronExpression == "0 0 0 * *" {
|
|
|
|
schedule.CronExpression = "0 0 * * *"
|
|
|
|
} else {
|
|
|
|
revisedCronExpression := strings.Split(schedule.CronExpression, " ")
|
|
|
|
if len(revisedCronExpression) == 5 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
revisedCronExpression = revisedCronExpression[1:]
|
|
|
|
schedule.CronExpression = strings.Join(revisedCronExpression, " ")
|
|
|
|
}
|
|
|
|
|
|
|
|
err := m.scheduleService.UpdateSchedule(schedule.ID, &schedule)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|