How to handle Parallel GitHub Actions and Migrations in Django + React Projects
I'm working on a Django + React project, and we use GitHub Actions for CI/CD. The typical workflow when a pull request is raised involves running Selenium tests, which require a large dataset in the database to execute effectively. Once the tests pass, I merge the branch, triggering an AWS CodePipeline that goes through source, manual approval, and deployment stages.
The problem I'm facing is related to database migrations when multiple developers raise pull requests simultaneously. If I run the workflows in parallel, I end up with migration conflicts that cause issues down the road. However, if I run the workflows sequentially, the deployment process gets delayed, especially when there are several pull requests in the queue.
Current Setup
GitHub Actions- Runs on pull requests, runs Selenium tests, and applies migrations to a testing database.
AWS CodePipeline- After tests pass and PR is merged, it handles manual approval and deployment to production.
Database- I'm using a large dataset, and migrations are applied to both a testing database and the live database in different stages.
Concerns
Migration Conflicts- When workflows run in parallel and developers raise pull requests with migration changes, I face conflicts when these workflows try to run migrations on the test or live databases simultaneously.
Sequential Workflow- Running workflows one after another avoids conflicts, but significantly delays deployment when there are multiple pull requests waiting to be processed.
My Questions
What’s the best practice for managing migrations when multiple pull requests are raised with migration changes?
Is there a way to efficiently run parallel workflows without causing migration issues but still avoiding delays in deployment?
How can I ensure database migrations run smoothly and prevent conflicts when multiple developers contribute changes that require schema updates?
Any tips or suggestions on how to handle this situation would be really helpful!