Skip to content

Commit

Permalink
feat: option to configure pg migration logging (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x authored Apr 12, 2024
1 parent 164184d commit e99bfbb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/postgres/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PgMigrate from 'node-pg-migrate';
import { MigrationDirection } from 'node-pg-migrate/dist/types';
import { Logger as PgMigrateLogger, MigrationDirection } from 'node-pg-migrate/dist/types';
import { logger } from '../logger';
import { PgConnectionArgs, connectPostgres, standardizedConnectionArgs } from './connection';
import { isDevEnv, isTestEnv } from '../helpers/values';
Expand All @@ -11,6 +11,8 @@ export interface MigrationOptions {
logMigrations?: boolean;
/** Name of the table used for migrations. Defaults to `pgmigrations`. */
migrationsTable?: string;
/** Custom logging configuration */
logger?: PgMigrateLogger;
}

/**
Expand Down Expand Up @@ -50,7 +52,7 @@ export async function runMigrations(
},
migrationsTable: opts?.migrationsTable ?? 'pgmigrations',
schema: typeof args === 'string' ? 'public' : args.schema,
logger: {
logger: opts?.logger ?? {
info: msg => (opts?.logMigrations === true ? logger.info(msg) : {}),
warn: msg => logger.warn(msg),
error: msg => logger.error(msg),
Expand Down

0 comments on commit e99bfbb

Please sign in to comment.