fix(history): don't let different migration directories interfere with each other even though they share storage

This commit is contained in:
Joakim Carlstein 2023-11-24 11:10:01 +01:00
parent cf17e48f25
commit 9447d28ad8
4 changed files with 21 additions and 9 deletions

View file

@ -40,6 +40,13 @@ export default async function listCommand({ directory, reporter: reporterConfig,
const finishedMigrations: MigrationMetadataFinished[] = [];
for await (const migrationHistoryEntry of storage.getHistory()) {
const index = migrationFiles.findIndex((migrationFile) => migrationFile.name === migrationHistoryEntry.name);
if (index === -1) {
// Only care about entries that exists in the current migration directory
continue;
}
const filePath = path.resolve(cwd, directory, migrationHistoryEntry.name);
const finishedMigration: MigrationMetadataFinished = {
name: migrationHistoryEntry.name,
@ -65,11 +72,7 @@ export default async function listCommand({ directory, reporter: reporterConfig,
finishedMigrations.push(finishedMigration);
const index = migrationFiles.findIndex((migrationFile) => migrationFile.name === migrationHistoryEntry.name);
if (index !== -1) {
migrationFiles.splice(index, 1);
}
migrationFiles.splice(index, 1);
}
for await (const migration of migrationFiles) {