fix(migration): avoid mutating MIGRATIONS array in-place during sort

The prepareMigrations() function called MIGRATIONS.sort() which mutated
the module-level exported array. When the test setup ran migrations via
beforeAll(), the array was left in ascending order, causing the
migrations.spec.ts ordering test to fail.

Co-authored-by: Elian Doran <eliandoran@users.noreply.github.com>
This commit is contained in:
claude[bot]
2026-04-19 20:08:29 +00:00
parent b43841157e
commit fbbeee9e4d

View File

@@ -77,9 +77,9 @@ async function migrate() {
}
async function prepareMigrations(currentDbVersion: number): Promise<MigrationInfo[]> {
MIGRATIONS.sort((a, b) => a.version - b.version);
const sortedMigrations = [...MIGRATIONS].sort((a, b) => a.version - b.version);
const migrations: MigrationInfo[] = [];
for (const migration of MIGRATIONS) {
for (const migration of sortedMigrations) {
const dbVersion = migration.version;
if (dbVersion > currentDbVersion) {
if ("sql" in migration) {