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,16 +3,18 @@ import {Container, Inject, Injectable} from '../../di'
import {EventBus} from '../../event/EventBus'
import {Migrator} from '../migrations/Migrator'
import {Migrations} from '../services/Migrations'
// import {RollingBackMigrationEvent} from '../migrations/events/RollingBackMigrationEvent'
// import {RolledBackMigrationEvent} from '../migrations/events/RolledBackMigrationEvent'
import {RollingBackMigrationEvent} from '../migrations/events/RollingBackMigrationEvent'
import {RolledBackMigrationEvent} from '../migrations/events/RolledBackMigrationEvent'
import {EventSubscription} from '../../event/types'
import {NothingToMigrateError} from '../migrations/NothingToMigrateError'
import {CLIDirective} from '../../cli/decorators'
/**
* CLI directive that undoes applied migrations using the default Migrator.
* @fixme Support dry run mode
*/
@Injectable()
@CLIDirective()
export class RollbackDirective extends Directive {
@Inject()
protected readonly bus!: EventBus
@@ -85,13 +87,13 @@ export class RollbackDirective extends Directive {
* @protected
*/
protected async registerListeners(): Promise<void> {
// this.subscriptions.push(await this.bus.subscribe(RollingBackMigrationEvent, event => {
// this.info(`Rolling-back migration ${event.migration.identifier}...`)
// }))
//
// this.subscriptions.push(await this.bus.subscribe(RolledBackMigrationEvent, event => {
// this.success(`Rolled-back migration: ${event.migration.identifier}`)
// }))
this.subscriptions.push(await this.bus.subscribe(RollingBackMigrationEvent, event => {
this.info(`Rolling-back migration ${event.migration.identifier}...`)
}))
this.subscriptions.push(await this.bus.subscribe(RolledBackMigrationEvent, event => {
this.success(`Rolled-back migration: ${event.migration.identifier}`)
}))
}
/** Remove event bus listeners before finish. */