diff --git a/packages/db-migrations/package.json b/packages/db-migrations/package.json index b1bb26c9b..0fdee48d6 100644 --- a/packages/db-migrations/package.json +++ b/packages/db-migrations/package.json @@ -1,6 +1,6 @@ { "name": "@serlo/db-migrations", - "version": "1.1.0-staging.3", + "version": "1.1.0-staging.4", "private": true, "license": "Apache-2.0", "type": "module", diff --git a/packages/db-migrations/src/20240624000000-replace-links-to-course-pages.ts b/packages/db-migrations/src/20240624000000-replace-links-to-course-pages.ts index 8d168ac2e..208e4b024 100644 --- a/packages/db-migrations/src/20240624000000-replace-links-to-course-pages.ts +++ b/packages/db-migrations/src/20240624000000-replace-links-to-course-pages.ts @@ -80,8 +80,10 @@ function replaceLinks(object: object, coursePages: CoursePage[]) { if (regex.test(object.href)) { const isFirstPage = - coursePages.find((page) => page.courseId === courseId) - ?.coursePageId === coursePageId + coursePages + .filter((page) => page.courseId === courseId) + .sort((a, b) => a.coursePageId - b.coursePageId)[0] + .coursePageId === coursePageId if (isFirstPage) { object.href = `/${courseId}` } else {