Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): application migrations #602

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

guidojw
Copy link
Owner

@guidojw guidojw commented Sep 23, 2023

Implements an application migrations system in the code, useful for e.g. migrating Discord resources after the database migrations have run.
Added an activation handler on the new migration service identifier that automatically passes a query runner to the migrations, so that the client does not have to instance one.

@guidojw guidojw added the enhancement New feature or request label Sep 23, 2023
@guidojw
Copy link
Owner Author

guidojw commented Sep 23, 2023

Chose to pass a query runner rather than using repositories as after new features/refactors, previously used repositories may not exist anymore breaking backwards compatibility. Using the query runner, this will not happen. Since the migrations are bound in the DI container, dependencies can still be injected in them if necessary.

return target.apply(thisArgument, [...argumentsList, dataSource.createQueryRunner()])
}
}
if (typeof migration.shouldRun !== 'undefined') {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just remove this

@@ -132,6 +137,14 @@ export default class AroraClient<Ready extends boolean = boolean> extends Client
return usedToken
}

private async runMigrations (): Promise<void> {
for (const migration of this.migrations) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort by name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant