diff --git a/changelog.d/3-bug-fixes/WPB-4425-fix-es-migration-script b/changelog.d/3-bug-fixes/WPB-4425-fix-es-migration-script new file mode 100644 index 0000000000..66cbb38478 --- /dev/null +++ b/changelog.d/3-bug-fixes/WPB-4425-fix-es-migration-script @@ -0,0 +1 @@ +Fix ES migration script. diff --git a/services/brig/src/Brig/Index/Migrations.hs b/services/brig/src/Brig/Index/Migrations.hs index c6101df53a..27d7559fed 100644 --- a/services/brig/src/Brig/Index/Migrations.hs +++ b/services/brig/src/Brig/Index/Migrations.hs @@ -120,21 +120,21 @@ failIfIndexAbsent targetIndex = -- | Runs only the migrations which need to run runMigration :: MigrationVersion -> MigrationActionT IO () -runMigration ver = do - vmax <- latestMigrationVersion - if ver > vmax +runMigration expectedVersion = do + foundVersion <- latestMigrationVersion + if expectedVersion > foundVersion then do Log.info $ Log.msg (Log.val "Migration necessary.") - . Log.field "expectedVersion" vmax - . Log.field "foundVersion" ver + . Log.field "expectedVersion" expectedVersion + . Log.field "foundVersion" foundVersion Search.reindexAllIfSameOrNewer - persistVersion ver + persistVersion expectedVersion else do Log.info $ Log.msg (Log.val "No migration necessary.") - . Log.field "expectedVersion" vmax - . Log.field "foundVersion" ver + . Log.field "expectedVersion" expectedVersion + . Log.field "foundVersion" foundVersion persistVersion :: (MonadThrow m, MonadIO m) => MigrationVersion -> MigrationActionT m () persistVersion v = @@ -148,6 +148,7 @@ persistVersion v = . Log.field "migrationVersion" v else throwM $ PersistVersionFailed v $ show persistResponse +-- | Which version is the table space currently running on? latestMigrationVersion :: (MonadThrow m, MonadIO m) => MigrationActionT m MigrationVersion latestMigrationVersion = do resp <- ES.parseEsResponse =<< ES.searchByIndex indexName (ES.mkSearch Nothing Nothing)