Add a Django DB migration script compatible with GitOps
This is simple in principle, but is complicated by the requirement of rolling back by running a historic pipeline. What's needed is a data snapshot coupled to the Git SHA, and ensure that it's deployed together.
A possible solution:
•Deployment Repo
→ incoming commit of tfvars plus the new Git SHA (of the application build commit)
→ pipeline triggered
→ job checks for previous data snapshot tagged with the new Git SHA
true: write pipeline stage to restore that snapshot
false: write pipeline stage to take a snapshot tagged with the existing Git SHA
→ job Terraform plan
→ job Terraform apply
run that pipeline stage
run terraform apply
... then the migration job can follow