# DB Jobs for dev-lti

These manifests are intended for EKS + Argo CD deployment flow.

## Files
- `migrate-dev-lti-presync.yaml`: Argo CD `PreSync` migration Job.
- `seed-dev-lti-manual.yaml`: manual seed Job.
- `fresh-dev-lti-manual.yaml`: manual reset + migrate Job (guarded with `ALLOW_DB_RESET`).

## Important
- Update the image tag in all manifests to the same tag deployed by Argo for each release.
- Jobs currently read environment variables from secret `lti-env-dev`.
- Required DB env vars: `DB_HOST`, `DB_PORT`, `DB_USER`, `DB_PASSWORD`, `DB_NAME`, optional `DB_SSLMODE`.

## Manual run
Seed:

```bash
kubectl delete job -n dev-lti lti-db-seed-manual --ignore-not-found
kubectl apply -f k8s/jobs/seed-dev-lti-manual.yaml
kubectl logs -n dev-lti job/lti-db-seed-manual -f
```

Fresh/reset (dev only):

```bash
kubectl delete job -n dev-lti lti-db-fresh-manual --ignore-not-found
sed 's/value: "NO"/value: "YES"/' k8s/jobs/fresh-dev-lti-manual.yaml | kubectl apply -f -
kubectl logs -n dev-lti job/lti-db-fresh-manual -f
```

## Argo CD note
For `migrate-dev-lti-presync.yaml`, keep annotation:

- `argocd.argoproj.io/hook: PreSync`
- `argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded`

so migration runs before workload sync.
