mirror of
https://github.com/directus/directus.git
synced 2026-02-11 18:55:01 -05:00
Check for duplicate migration keys (#8597)
* Check for duplicate migration keys * Run prettier
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user