From af06f2f65c0e87cbc8b295b5cbfa4e6895121459 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Thu, 25 Nov 2021 00:14:43 +0100 Subject: [PATCH] fix: always move auth module migration to the end --- types/module/module.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/types/module/module.go b/types/module/module.go index 57b2df544378..0159145b4e18 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -395,10 +395,19 @@ func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM Version // and the order of executing migrations matters) // TODO: make the order user-configurable? sortedModNames := make([]string, 0, len(m.Modules)) + hasAuth := false + const authModulename = "auth" // using authtypes.ModuleName causes import cycle. for key := range m.Modules { - sortedModNames = append(sortedModNames, key) + if key != authModulename { + sortedModNames = append(sortedModNames, key) + } else { + hasAuth = true + } } sort.Strings(sortedModNames) + if hasAuth { + sortedModNames = append(sortedModNames, authModulename) + } for _, moduleName := range sortedModNames { module := m.Modules[moduleName]