I would use two separate projects. One would set up your base infra including the longer-running scripts that cause the problem. The next would set up the application-specific infra, including your DB migration. That allows you to put a health check in your deployment script or similar, between running the two projects.