payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
27.76k stars 1.72k forks source link

fix: correct migrations sorting in `getMigrations` #9330

Open r1tsuu opened 3 days ago

r1tsuu commented 3 days ago

What?

We sorted migrations by -name in getMigrations as by assumption from generated file names, however, it may be not true as the improved (+ unflaked, previously it failed sometimes) test for migrate:down can reproduce. As in result, migrateDown / migrateRefresh may execute in order different from migrate.

Unflakes the 'should commit multiple operations async' test. We shouldn't pass the same req that doesn't contain a transaction to different operations that execute in parallel (via Promise.all) without either creating a transaction before or using isolateObjectProperty(req, 'transactionID'). It leads to a race condition because operation can commit a wrong transaction, different from inited