Skip to content

Commit

Permalink
fix(pino): show correct statuses for the "list" and "new" commands
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimbeng committed Feb 12, 2024
1 parent 17feb2d commit 1065322
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-timers-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emigrate/reporter-pino': patch
---

Show correct status for migrations for the "list" and "new" commands
18 changes: 16 additions & 2 deletions packages/reporter-pino/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`);
}

Expand Down

0 comments on commit 1065322

Please sign in to comment.