Skip to content

Commit

Permalink
fix(mongo-migrations): fix logging of executed migrations
Browse files Browse the repository at this point in the history
Closes #4698
  • Loading branch information
B4nan committed Sep 21, 2023
1 parent 59a6fae commit 8ae7eeb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/cli/src/commands/MigrationCommandFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
import { Utils, colors, type Configuration, type MikroORM, type MikroORMOptions, type IMigrator } from '@mikro-orm/core';
import {
Utils,
colors,
type Configuration,
type MikroORM,
type MikroORMOptions,
type IMigrator,
type Dictionary,
} from '@mikro-orm/core';
import type { MigrateOptions } from '@mikro-orm/migrations';
import { CLIHelper } from '../CLIHelper';

Expand Down Expand Up @@ -147,7 +155,11 @@ export class MigrationCommandFactory {

CLIHelper.dumpTable({
columns: ['Name', 'Executed at'],
rows: executed.map(row => [row.name.replace(/\.[jt]s$/, ''), row.executed_at?.toISOString()]),
rows: executed.map(row => {
/* istanbul ignore next */
const executedAt = (row.executed_at ?? (row as Dictionary).created_at)?.toISOString() ?? '';
return [row.name.replace(/\.[jt]s$/, ''), executedAt];
}),
empty: 'No migrations executed yet',
});
}
Expand Down

0 comments on commit 8ae7eeb

Please sign in to comment.