# DurableTask SQL schema migration Job

1. Copy this directory into the release repository and set the package version in the project to the exact provider version shipped by the workers.
2. Build it with `docker build -t REGISTRY/durable-sql-schema-migrator:TAG .` and push that image.
3. Run `preflight.sql` against the production database. Save its output and take the database backup required by your change policy.
4. Replace the image, namespace, and secret reference in `job.yaml`. The secret must contain the migration connection string; keep it out of Git.
5. Apply and wait: `kubectl apply -f job.yaml && kubectl wait --for=condition=complete job/durable-sql-schema-upgrade -n NAMESPACE --timeout=10m`.
6. Capture `kubectl logs job/durable-sql-schema-upgrade -n NAMESPACE` and run `postflight.sql`.
7. Only then roll one worker replica, resume a known waiting orchestration, and widen the rollout.

If the Job fails, do not start workers hoping they will fix it. Keep workers stopped, retain the Job logs, and decide from a restored rehearsal whether rerunning the same release is safe. Restoring a database requires redeploying the matching worker/provider image as well.
