From e78aaec558f91b339e126f68cd93f1b63a32be54 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Sat, 25 Jul 2020 11:10:46 +1200 Subject: [PATCH] feat(api/bolt): update DBVersion to 25 --- api/bolt/migrator/migrate_dbversion23.go | 18 ++---------------- api/bolt/migrator/migrate_dbversion24.go | 20 ++++++++++++++++++++ api/bolt/migrator/migrator.go | 10 +++++++++- api/portainer.go | 2 +- 4 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 api/bolt/migrator/migrate_dbversion24.go diff --git a/api/bolt/migrator/migrate_dbversion23.go b/api/bolt/migrator/migrate_dbversion23.go index 01c97d152..f106038b5 100644 --- a/api/bolt/migrator/migrate_dbversion23.go +++ b/api/bolt/migrator/migrate_dbversion23.go @@ -1,20 +1,6 @@ package migrator -import ( - "github.com/portainer/portainer/api" -) - func (m *Migrator) updateSettingsToDB24() error { - legacySettings, err := m.settingsService.Settings() - if err != nil { - return err - } - - if legacySettings.TemplatesURL == "" { - legacySettings.TemplatesURL = portainer.DefaultTemplatesURL - } - - legacySettings.UserSessionTimeout = portainer.DefaultUserSessionTimeout - - return m.settingsService.UpdateSettings(legacySettings) + // Placeholder for 1.24.1 backports + return nil } diff --git a/api/bolt/migrator/migrate_dbversion24.go b/api/bolt/migrator/migrate_dbversion24.go new file mode 100644 index 000000000..d1dc5f0cf --- /dev/null +++ b/api/bolt/migrator/migrate_dbversion24.go @@ -0,0 +1,20 @@ +package migrator + +import ( + "github.com/portainer/portainer/api" +) + +func (m *Migrator) updateSettingsToDB25() error { + legacySettings, err := m.settingsService.Settings() + if err != nil { + return err + } + + if legacySettings.TemplatesURL == "" { + legacySettings.TemplatesURL = portainer.DefaultTemplatesURL + } + + legacySettings.UserSessionTimeout = portainer.DefaultUserSessionTimeout + + return m.settingsService.UpdateSettings(legacySettings) +} diff --git a/api/bolt/migrator/migrator.go b/api/bolt/migrator/migrator.go index a933b6519..598681f28 100644 --- a/api/bolt/migrator/migrator.go +++ b/api/bolt/migrator/migrator.go @@ -321,7 +321,7 @@ func (m *Migrator) Migrate() error { } } - // Portainer 2.0 + // Portainer 1.24.1 if m.currentDBVersion < 24 { err := m.updateSettingsToDB24() if err != nil { @@ -329,5 +329,13 @@ func (m *Migrator) Migrate() error { } } + // Portainer 2.0 + if m.currentDBVersion < 25 { + err := m.updateSettingsToDB25() + if err != nil { + return err + } + } + return m.versionService.StoreDBVersion(portainer.DBVersion) } diff --git a/api/portainer.go b/api/portainer.go index 428b07c97..fa2a8afcc 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -1118,7 +1118,7 @@ const ( // APIVersion is the version number of the Portainer API APIVersion = "2.0.0-dev" // DBVersion is the version number of the Portainer database - DBVersion = 24 + DBVersion = 25 // AssetsServerURL represents the URL of the Portainer asset server AssetsServerURL = "https://portainer-io-assets.sfo2.digitaloceanspaces.com" // MessageOfTheDayURL represents the URL where Portainer MOTD message can be retrieved