chore(migration): fix oauth2 migration
This commit is contained in:
parent
843e6dbba2
commit
770c2f3182
@ -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|
|
[executeQQ|
|
||||||
ALTER TABLE "user" ADD COLUMN "password_hash" VARCHAR NULL;
|
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; |]
|
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 [ 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
|
in runConduit $ getPWHashes .| C.mapM_ migratePWHash
|
||||||
[executeQQ|
|
[executeQQ|
|
||||||
ALTER TABLE "user" DROP COLUMN "authentication";
|
ALTER TABLE "user" DROP COLUMN "authentication";
|
||||||
|
|||||||
Reference in New Issue
Block a user