fix(pino): show correct statuses for the "list" and "new" commands

This commit is contained in:
Joakim Carlstein 2024-02-12 13:35:06 +01:00 committed by Joakim Carlstein
parent 17feb2d2c2
commit 1065322435
2 changed files with 21 additions and 2 deletions

View file

@ -116,12 +116,26 @@ class PinoReporter implements Required<EmigrateReporter> {
}
onMigrationStart(migration: MigrationMetadata): Awaitable<void> {
const status = this.#command === 'up' ? 'running' : 'removing';
let status = 'running';
if (this.#command === 'remove') {
status = 'removing';
} else if (this.#command === 'new') {
status = 'creating';
}
this.#logger.info({ migration: migration.relativeFilePath }, `${migration.name} (${status})`);
}
onMigrationSuccess(migration: MigrationMetadataFinished): Awaitable<void> {
const status = this.#command === 'up' ? 'done' : 'removed';
let status = 'done';
if (this.#command === 'remove') {
status = 'removed';
} else if (this.#command === 'new') {
status = 'created';
}
this.#logger.info({ migration: migration.relativeFilePath }, `${migration.name} (${status})`);
}