I have a multi-server laravel php application running behind a load balancer and I deploy the code using aws codebuild and codepipeline. The approach is to deploy my application one server at the time.
Also, the application uses a postgresql database that was manually generated without any sort of migration script. Therefore, I introduced a database migration scheme.
The pipeline for the production goes as follows:
- Fetch the code from master branch. (Master is the production branch)
- Install dependencies and run tests.
- Deploy to the servers, one at a time.
So I want to add the step that databases are being migrated but I do not know where this step should be executed. Should be executed before deployment to the servers or during server deployment once code successfully has been deployed to one server?
Because the schema previously had no migration scripts I want to ensure that no data corruption will occur during deployment and the downtime will be minimal as possible.