Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(bootstrap): Fix issues with the registration of metadata not…
… going to the correct static constructor, implement migration bootstrapping
- Loading branch information
Showing
13 changed files
with
73 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ResolvedReflectiveProvider } from '@angular/core'; | ||
import { EntityBootstrapper } from './entity.bootstrapper'; | ||
import { BaseMigration } from '../migrations/index'; | ||
|
||
export class MigrationBootstrapper extends EntityBootstrapper { | ||
|
||
public getResolvedEntities(): ResolvedReflectiveProvider[] { | ||
return this.getResolvedFromRegistry('migration'); | ||
} | ||
|
||
public bootstrap(): Promise<void> { | ||
|
||
this.logger.debug(`Running [${this.resolvedEntityProviders.length}] migrations`); | ||
|
||
const allMigrationPromises = this.resolvedEntityProviders.map((resolvedControllerProvider: ResolvedReflectiveProvider) => { | ||
|
||
this.logger.info(`migrating ${resolvedControllerProvider.key.displayName}`); | ||
return (this.injector.instantiateResolved(resolvedControllerProvider) as BaseMigration).migrate(); | ||
|
||
}, []); | ||
|
||
return Promise.all(allMigrationPromises); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Database } from '../services/database.service'; | ||
import { Logger } from '../../common/services/logger.service'; | ||
export abstract class BaseMigration { | ||
|
||
protected logger:Logger; | ||
constructor(loggerBase:Logger, protected database:Database){ | ||
this.logger = loggerBase.source(this.constructor.name); | ||
|
||
} | ||
|
||
public abstract migrate():Promise<void>; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters