From 8c4203dc72cc2659044941cdcdfdf96667b53987 Mon Sep 17 00:00:00 2001 From: Lucas Beiknejad Date: Fri, 24 Jul 2026 10:06:42 +0200 Subject: [PATCH] Show points of inconsistency in error message to easier find inconsistencies in migration_ids --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5ef5faa..ef80b30 100644 --- a/index.js +++ b/index.js @@ -20,8 +20,19 @@ export default async function({ const latest = migrations[migrations.length - 1] - if (latest.migration_id !== migrations.length) - throw new Error('Inconsistency in migration numbering') + if (latest.migration_id !== migrations.length) { + let numbers = [] + + for (const [i, m] of migrations.entries()) { + if (i === 0 || i + 1 === migrations.length) + continue + + if (m.migration_id + 1 !== migrations[i + 1].migration_id) + numbers.push(m.migration_id) + } + + throw new Error('Inconsistency in migration numbering at: ' + numbers.map(x => x).join(', ')) + } await ensureMigrationsTable()