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

@@ -1,18 +1,20 @@
import {Directive, OptionDefinition} from '../../cli'
import {Container, Inject, Injectable} from '../../di'
import {EventBus} from '../../event/EventBus'
import {Migrator} from '../migrations/Migrator'
import {Migrations} from '../services/Migrations'
// import {ApplyingMigrationEvent} from '../migrations/events/ApplyingMigrationEvent'
// import {AppliedMigrationEvent} from '../migrations/events/AppliedMigrationEvent'
import {Migrator} from '../migrations/Migrator'
import {ApplyingMigrationEvent} from '../migrations/events/ApplyingMigrationEvent'
import {AppliedMigrationEvent} from '../migrations/events/AppliedMigrationEvent'
import {EventSubscription} from '../../event/types'
import {NothingToMigrateError} from '../migrations/NothingToMigrateError'
import {CLIDirective} from '../../cli/decorators'
/**
* CLI directive that applies migrations using the default Migrator.
* @fixme Support dry run mode
*/
@Injectable()
@CLIDirective()
export class MigrateDirective extends Directive {
@Inject()
protected readonly bus!: EventBus
@@ -100,13 +102,13 @@ export class MigrateDirective extends Directive {
* @protected
*/
protected async registerListeners(): Promise<void> {
// this.subscriptions.push(await this.bus.subscribe(ApplyingMigrationEvent, event => {
// this.info(`Applying migration ${event.migration.identifier}...`)
// }))
//
// this.subscriptions.push(await this.bus.subscribe(AppliedMigrationEvent, event => {
// this.success(`Applied migration: ${event.migration.identifier}`)
// }))
this.subscriptions.push(await this.bus.subscribe(ApplyingMigrationEvent, event => {
this.info(`Applying migration ${event.migration.identifier}...`)
}))
this.subscriptions.push(await this.bus.subscribe(AppliedMigrationEvent, event => {
this.success(`Applied migration: ${event.migration.identifier}`)
}))
}
/** Remove event bus listeners before finish. */