mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 20:17:01 +02:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user