Fix circular dependencies in migrator
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-09-21 13:42:06 -05:00
parent 074a3187eb
commit 5940b6e2b3
24 changed files with 2818 additions and 2729 deletions

View File

@@ -3,10 +3,10 @@ import {Awaitable, collect, ErrorWithContext} from '../../util'
import {Migration} from './Migration'
import {Migrations} from '../services/Migrations'
import {EventBus} from '../../event/EventBus'
// import {ApplyingMigrationEvent} from './events/ApplyingMigrationEvent'
// import {AppliedMigrationEvent} from './events/AppliedMigrationEvent'
// import {RollingBackMigrationEvent} from './events/RollingBackMigrationEvent'
// import {RolledBackMigrationEvent} from './events/RolledBackMigrationEvent'
import {ApplyingMigrationEvent} from './events/ApplyingMigrationEvent'
import {AppliedMigrationEvent} from './events/AppliedMigrationEvent'
import {RollingBackMigrationEvent} from './events/RollingBackMigrationEvent'
import {RolledBackMigrationEvent} from './events/RolledBackMigrationEvent'
import {NothingToMigrateError} from './NothingToMigrateError'
/**
@@ -14,7 +14,7 @@ import {NothingToMigrateError} from './NothingToMigrateError'
*/
@Injectable()
export abstract class Migrator {
@Inject()
@Inject(Migrations, { debug: true })
protected readonly migrations!: Migrations
@Inject()
@@ -259,8 +259,8 @@ export abstract class Migrator {
* @protected
*/
protected async applying(migration: Migration): Promise<void> {
// const event = <ApplyingMigrationEvent> this.injector.make(ApplyingMigrationEvent, migration)
// await this.bus.dispatch(event)
const event = <ApplyingMigrationEvent> this.injector.make(ApplyingMigrationEvent, migration)
await this.bus.dispatch(event)
}
/**
@@ -269,8 +269,8 @@ export abstract class Migrator {
* @protected
*/
protected async applied(migration: Migration): Promise<void> {
// const event = <AppliedMigrationEvent> this.injector.make(AppliedMigrationEvent, migration)
// await this.bus.dispatch(event)
const event = <AppliedMigrationEvent> this.injector.make(AppliedMigrationEvent, migration)
await this.bus.dispatch(event)
}
/**
@@ -279,8 +279,8 @@ export abstract class Migrator {
* @protected
*/
protected async rollingBack(migration: Migration): Promise<void> {
// const event = <RollingBackMigrationEvent> this.injector.make(RollingBackMigrationEvent, migration)
// await this.bus.dispatch(event)
const event = <RollingBackMigrationEvent> this.injector.make(RollingBackMigrationEvent, migration)
await this.bus.dispatch(event)
}
/**
@@ -289,7 +289,7 @@ export abstract class Migrator {
* @protected
*/
protected async rolledBack(migration: Migration): Promise<void> {
// const event = <RolledBackMigrationEvent> this.injector.make(RolledBackMigrationEvent, migration)
// await this.bus.dispatch(event)
const event = <RolledBackMigrationEvent> this.injector.make(RolledBackMigrationEvent, migration)
await this.bus.dispatch(event)
}
}