1+ import Logger , { ConsoleLogger } from "../common/Logger.js" ;
12import { modelSymbol } from "../common/symbols/symbols.js" ;
23import type QueryCompiler from "../compiler/QueryCompiler.js" ;
34import ICheckConstraint from "../decorators/ICheckConstraint.js" ;
@@ -11,28 +12,34 @@ import type EntityQuery from "../model/EntityQuery.js";
1112
1213export default abstract class Migrations {
1314
15+ logger : Logger ;
16+
1417 constructor (
1518 private context : EntityContext ,
1619 private connection : BaseConnection = context . connection ,
1720 protected compiler : QueryCompiler = context . driver . compiler
18- ) { }
21+ ) {
22+
23+ }
1924
2025 public async migrate ( {
2126 version,
2227 name = "default" ,
2328 historyTableName = "migrations" ,
29+ log = new ConsoleLogger ( false ) ,
2430 seed,
2531 createIndexForForeignKeys = true
2632 } : {
2733 version ?: string ,
2834 name ?: string ,
29- historyTableName ?:
30- string ,
35+ historyTableName ?: string ,
36+ log ?: Logger ,
3137 seed ?: ( c : EntityContext ) => Promise < any > ,
3238 createIndexForForeignKeys ?: boolean
3339 } = { } ) {
3440 const { context } = this ;
3541 const { model } = context ;
42+ this . logger = log ?? context . logger ;
3643 const postMigration = [ ] as ( ( ) => Promise < void > ) [ ] ;
3744
3845 if ( version ) {
@@ -194,7 +201,7 @@ export default abstract class Migrations {
194201
195202 protected executeQuery ( command : IQuery , signal ?: AbortSignal ) : Promise < IQueryResult > {
196203 const text = typeof command === "string" ? command : command . text ;
197- this . context . logger ?. log ( text ) ;
204+ this . logger ?. log ( text ) ;
198205 return this . connection . executeQuery ( command , signal ) ;
199206 }
200207
0 commit comments