Repository navigation
Upgrade the v1 Cloud SQL schema and seed the v2 database side by side in the release run - #4130
Merged
Merged
Conversation
anth-volk
force-pushed
the
parallel-database-steps
branch
from
October 29, 2026 19:52
3c966ef to
fb00c49
Compare
anth-volk
force-pushed
the
parallel-database-steps
branch
from
October 29, 2026 20:13
fb00c49 to
3c966ef
Compare
In staging and in production, the v2 seeding job waits for the v1 Cloud SQL schema upgrade, though neither reads the other's database. These tests describe the next step: each seeding job starts with its v1 upgrade, both keep their environments and secrets, and each Cloud Run candidate deploy needs both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The v2 seeding jobs waited for the v1 schema upgrade in both environments. The order came in with the Stage 9 catalog (#3808), when one v1 upgrade job ran before staging, and was kept when #3813 split it per environment; neither says why. Neither job reads the other's database: migrate-v1-cloud-sql.yml connects only to Cloud SQL through its proxy, and seed-v2-database.yml only to the v2 database, with no Cloud SQL proxy, GCP sign-in or v1 credentials. Each seeding job now starts with its v1 upgrade. deploy-cloud-run-staging already needed both; deploy-cloud-run-candidate now needs migrate-v1-production-cloud-sql as well as the production seeding, so neither candidate is built until both databases are upgraded. The jobs keep their environments and secrets: inherit. alembic-migrations.md records the order, and that a release which stops can now leave either database upgraded without the other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
force-pushed
the
parallel-database-steps
branch
from
October 29, 2026 21:01
3c966ef to
3a7ed9a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4130 +/- ##
===========================================
+ Coverage 50.56% 88.13% +37.56%
===========================================
Files 257 273 +16
Lines 14864 16299 +1435
Branches 2378 2668 +290
===========================================
+ Hits 7516 14365 +6849
+ Misses 6718 1268 -5450
- Partials 630 666 +36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4129
Stacked on #4127.
Summary
seed-v2-staging-databaseno longer needsmigrate-v1-staging-cloud-sql, andseed-v2-production-databaseno longer needsmigrate-v1-production-cloud-sql. In each environment the two database jobs start together.deploy-cloud-run-candidateneedsmigrate-v1-production-cloud-sqlas well asseed-v2-production-database.deploy-cloud-run-stagingalready needed both staging jobs. No candidate is built until both databases are upgraded.docs/engineering/skills/alembic-migrations.mdrecords the order, and that a release that stops can now leave either database upgraded without the other.test_v1_upgrade_and_v2_seeding_run_side_by_sidechecks, for staging and production, that neither database job needs the other, that both start after the same job, and that the v1 upgrade keepsdeployment_environment, its<environment>-databaseGitHub environment andsecrets: inherit.test_seeding_success_is_required_before_candidate_creationchecks that each candidate deploy needs both. The other order tests are updated to match.No inline ruff suppressions are added.
Why the seeding waited for the upgrade
I found no dependency between the two jobs:
migrate-v1-cloud-sql.ymlsigns in to Google Cloud asGCP_DB_MIGRATION_SERVICE_ACCOUNT, starts the Cloud SQL Auth Proxy and runsmigrate_v1_cloud_sql.sh. That script reads the Cloud SQL credentials from Secret Manager, takes a backup when revisions are pending, and upgrades and verifies the v1 schema.seed-v2-database.ymlhas no Google Cloud sign-in, no proxy and no v1 credentials. Every step reads onlyV2_MIGRATION_DATABASE_URLorV2_DATA_WRITE_DATABASE_URL, and the modules they run (policy_migration_qualification,household_migration_qualification,user_association_migration_qualification,privilege_reconciliation,catalog.initialization) import only v2 models and settings. No v2 Alembic revision reads MySQL.git log -Sfinds the order in two commits.78e380bbd(Implement Stage 9 v2 metadata catalog and preview routes #3808, Stage 9) addedinitialize-v2-stagingwithneeds: [publish-git-tag, migrate-v1-cloud-sql], when one v1 upgrade job ran before staging; its production twin waited for no v1 upgrade.f410bcac1(Implement Phase 10 API v2 policy migration #3813, Phase 10) split the v1 upgrade per environment, kept the staging order and made the production seeding wait for the production upgrade. Neither commit message, PR description nor the Stage 9 to 12A migration docs says why. Stage 10 and Stage 11 require only that both schemas are applied before the candidate is built, and the Stage 11 staging qualification ran the two schema workflows separately.What changes when a release stops: today a v1 upgrade failure stops the release before the v2 seeding starts. Now the seeding may already have upgraded the v2 schema and published the catalog when the v1 upgrade fails, so the serving revision can run with an upgraded v2 database and the previous v1 schema. It already runs with both databases upgraded from the seeding until promotion, and with only the v1 database upgraded when the seeding fails before its schema upgrade step. Nothing in the v1 upgrade depends on v2 state, and the serving revision's v1 queries use only the v1 schema.
Job dependencies on a release run
Before:
After:
Expected saving (minutes, measured medians of releases #2577 to #2608): 1.8 in production. In staging, up to 2.0 once the release tests are no longer the longer branch: with #4125 alone they take about as long as the staging database jobs, so the staging saving appears only with #4134, which shortens the tests. About 3.8 in all with the whole stack.
Environment variables
No job moves and no wiring changes. Each reusable workflow keeps its own
environment:and gets the caller's secrets throughsecrets: inherit.DEPLOYMENT_ENVIRONMENTwith: deployment_environmentenv:frominputs.POLICYENGINE_DB_INSTANCE_CONNECTION_NAME,POLICYENGINE_DB_READONLY_PASSWORD_SECRET,POLICYENGINE_DB_MIGRATION_PASSWORD_SECRETstaging-database/production-databaseenvironment variables (the first overrides the repository variable of the same name)env:withenvironment: ${{ inputs.github_environment }}PRODUCTION_POLICYENGINE_DB_INSTANCE_CONNECTION_NAME,PRODUCTION_POLICYENGINE_DB_READONLY_PASSWORD_SECRET,PRODUCTION_POLICYENGINE_DB_MIGRATION_PASSWORD_SECRETenv:GCP_WORKLOAD_IDENTITY_PROVIDERsecrets: inherit, thenwith:ofgoogle-github-actions/authGCP_DB_MIGRATION_SERVICE_ACCOUNTwith:ofgoogle-github-actions/authpermissions: id-token: writein the reusable jobDEPLOYMENT_ENVIRONMENTwith: deployment_environmentenv:frominputs.V2_SUPABASE_PROJECT_REF,V2_SUPABASE_ENVIRONMENTstaging/productionenvironment variablesenv:withenvironment: ${{ inputs.deployment_environment }}PRODUCTION_V2_SUPABASE_PROJECT_REFenv:V2_MIGRATION_DATABASE_URL,V2_DATA_WRITE_DATABASE_URLstaging/productionenvironment secretssecrets: inherit, then stepenv:All names were confirmed with read-only
gh apicalls that list names only (actions/secrets,actions/variables, andenvironments/<name>/secretsand/variablesforstaging,production,staging-databaseandproduction-database).Google Cloud sign-in: only the v1 upgrade signs in, and it keeps its
staging-databaseorproduction-databaseenvironment, so its OIDC token is unchanged. The seeding job does not sign in.Unverified until the first release after merge
push.ymlruns only on pushes tomaster, so this pull request's CI does not run these jobs.Testing
pytest tests/unit/v2/test_metadata_deployment.py tests/unit/test_app_engine_decommission.py tests/unit/test_cloud_run_push_workflow.py: 4 failed, 25 passed.ruff format --check .andruff check .with the ruff versionuv.lockpins (0.15.12): clean.python scripts/run_quality_guards.py: passed.python -m scripts.rules guard --base-ref origin/master: passed. The rules tool's tests: OK.python -m scripts.rules render: no diff.uv lock --check: passed.push.ymlparses as YAML and passesactionlint.🤖 Generated with Claude Code