From 0d7d63f9fe757e60ea1bc305dee19b7a39ef6436 Mon Sep 17 00:00:00 2001 From: heyarne Date: Fri, 8 Oct 2021 00:00:31 +0200 Subject: [PATCH] Check for duplicate migration keys (#8597) * Check for duplicate migration keys * Run prettier --- api/src/database/migrations/run.ts | 5 +++++ docs/guides/users.md | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/database/migrations/run.ts b/api/src/database/migrations/run.ts index 58a1af398b..85003aafdf 100644 --- a/api/src/database/migrations/run.ts +++ b/api/src/database/migrations/run.ts @@ -26,6 +26,11 @@ export default async function run(database: Knex, direction: 'up' | 'down' | 'la ...customMigrationFiles.map((path) => parseFilePath(path, true)), ].sort((a, b) => (a.version > b.version ? 1 : -1)); + const migrationKeys = new Set(migrations.map((m) => m.version)); + if (migrations.length > migrationKeys.size) { + throw new Error('Migration keys collide! Please ensure that every migration uses a unique key.'); + } + function parseFilePath(filePath: string, custom = false) { const version = filePath.split('-')[0]; const name = formatTitle(filePath.split('-').slice(1).join('_').split('.')[0]); diff --git a/docs/guides/users.md b/docs/guides/users.md index 5e23390d3d..dc3522dda9 100644 --- a/docs/guides/users.md +++ b/docs/guides/users.md @@ -14,8 +14,8 @@ 1. Navigate to the **User Library** 2. Click the **Invite Users** button in the header -4. Enter **one or more email addresses**, separated by new lines, in the modal -5. Click **Invite** +3. Enter **one or more email addresses**, separated by new lines, in the modal +4. Click **Invite** At this point the invited user(s) will receive an email with a link to the App where they set a password and enable their account.