diff --git a/test/unit/pg-log-writer.test.mjs b/test/unit/pg-log-writer.test.mjs index d1c5bba7c..f8b0bbb92 100644 --- a/test/unit/pg-log-writer.test.mjs +++ b/test/unit/pg-log-writer.test.mjs @@ -181,7 +181,13 @@ test('PG migrations 011 and 012 optimize usage_logs/request_attempts/account_all const mockPool = { connect: async () => client } const first = await applyPgMigrations(mockPool) - assert.equal(first.at(-1), mig012) + // The runner applies every migration file in order; do not pin 012 as the last one (newer migrations land after it). + const migrationFiles = fs + .readdirSync(PG_MIGRATIONS_DIR) + .filter((name) => name.endsWith('.sql')) + .sort() + assert.equal(first.at(-1), migrationFiles.at(-1)) + assert.ok(first.includes(mig011) && first.indexOf(mig012) > first.indexOf(mig011)) assert.ok(executedSql.some((s) => s.includes('DROP INDEX IF EXISTS idx_reqlog_cost_ts'))) assert.ok(executedSql.some((s) => s.includes('DROP INDEX IF EXISTS idx_request_attempt_request'))) assert.ok(executedSql.some((s) => s.includes('idx_alloc_account_id_desc')))