Skip to content

Run db-migrate Cloud Run job before updating services#400

Merged
Omicron7 merged 2 commits into
mainfrom
cloudrun-db-migrate
Jun 5, 2026
Merged

Run db-migrate Cloud Run job before updating services#400
Omicron7 merged 2 commits into
mainfrom
cloudrun-db-migrate

Conversation

@Omicron7
Copy link
Copy Markdown
Contributor

@Omicron7 Omicron7 commented Jun 3, 2026

Summary

  • deploy-cloudrun now looks for a Cloud Run job named db-migrate, created by the gcp/cloudrun/app terraform module when database_migrations is enabled (CruGlobal/cru-terraform-modules#635).
  • When present, the job image is updated and the job executed to completion before any service is updated — a failed migration fails the deploy and leaves the running services untouched.
  • Projects without the job are unaffected (lookup returns NOT_FOUND and the deploy proceeds as before).
  • Job updates use a full read-modify-write (like gcloud run jobs update) since UpdateJobRequest has no updateMask; the env merge logic is now shared between jobs and services.
  • dist/ rebuilt.

🤖 Generated with Claude Code

Omicron7 and others added 2 commits June 3, 2026 11:05
deploy-cloudrun now looks for a Cloud Run job named db-migrate (created
by the gcp/cloudrun/app terraform module when database_migrations is
enabled). When present, the job image is updated and the job executed
to completion before any service is updated — a failed migration fails
the deploy and leaves the running services untouched. Projects without
the job are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
deploy-cloudrun now lists all Cloud Run jobs and updates each job's
image and secrets, not just db-migrate. This keeps scheduled_jobs
(gcp/cloudrun/app) on the freshly built image instead of the stale
image resolved at terraform apply time.

db-migrate is still the only job executed during deploy (to completion,
before services and other jobs are touched); every other job is updated
in place and runs on its own Cloud Scheduler cron.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Omicron7 Omicron7 marked this pull request as ready for review June 5, 2026 14:04
@Omicron7 Omicron7 merged commit 551f4a9 into main Jun 5, 2026
1 check passed
@Omicron7 Omicron7 deleted the cloudrun-db-migrate branch June 5, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants