diff --git a/src/Model/Migration/Definitions.hs b/src/Model/Migration/Definitions.hs index 543f4121c..063bc985c 100644 --- a/src/Model/Migration/Definitions.hs +++ b/src/Model/Migration/Definitions.hs @@ -178,13 +178,13 @@ customMigrations = mapF $ \case ; |] - Migration20240312OAuth2 -> whenM (columnExists "user" "ldap_primary_key") $ do + Migration20240312OAuth2 -> whenM (andM [ columnNotExists "user" "password_hash", columnExists "user" "authentication", columnExists "user" "last_ldap_synchronisation", columnExists "user" "ldap_primary_key" ]) $ do [executeQQ| ALTER TABLE "user" ADD COLUMN "password_hash" VARCHAR NULL; |] let getPWHashes = [queryQQ| SELECT "id", "authentication"->'pw-hash' FROM "user" WHERE "authentication"->'pw-hash' IS NOT NULL; |] migratePWHash [ fromPersistValue -> Right (uid :: UserId), fromPersistValue -> Right (pwHash :: Text) ] = [executeQQ| UPDATE "user" SET "password_hash" = #{pwHash} WHERE "id" = #{uid}; |] - migratePWHash _ = error "otherwise case reached!" -- TODO: return () + migratePWHash _ = return () in runConduit $ getPWHashes .| C.mapM_ migratePWHash [executeQQ| ALTER TABLE "user" DROP COLUMN "authentication";