fix(history): don't let different migration directories interfere with each other even though they share storage
This commit is contained in:
parent
cf17e48f25
commit
9447d28ad8
4 changed files with 21 additions and 9 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,11 @@ export default async function upCommand({
|
|||
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;
|
||||
}
|
||||
|
||||
if (migrationHistoryEntry.status === 'failed') {
|
||||
const filePath = path.resolve(cwd, directory, migrationHistoryEntry.name);
|
||||
const finishedMigration: MigrationMetadataFinished = {
|
||||
|
|
@ -86,9 +91,7 @@ export default async function upCommand({
|
|||
failedEntries.push(finishedMigration);
|
||||
}
|
||||
|
||||
if (index !== -1) {
|
||||
migrationFiles.splice(index, 1);
|
||||
}
|
||||
migrationFiles.splice(index, 1);
|
||||
}
|
||||
|
||||
const migrationFileExtensions = new Set(migrationFiles.map((migration) => migration.extension));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue