Is there a good pattern for running database migrations within a CDK Pipeline?
Normally (without a CDK Pipeline) I would achieve this with a deploy script that:
- deploys the database stack
- waits for the database stack to complete
- runs the db migrations
- deploys the API stack
Is there any way to do this in a CDK Pipeline app (run migrations after the Database stack is deployed but before the API stack is)?
export class MyStage extends Stage {
constructor(scope: Construct, id: string, props?: StageProps) {
super(scope, id, props);
const dbStack = new DatabaseStack(this, 'Database');
const apiStack = new ApiStack(this, 'Api', {
dbUrl: dbStack.dbUrl
});
}
}