feat: drop solution-specific bundled build fields (contract) [4/4] - #851
Open
almeidaraul wants to merge 1 commit into
Open
feat: drop solution-specific bundled build fields (contract) [4/4]#851almeidaraul wants to merge 1 commit into
almeidaraul wants to merge 1 commit into
Conversation
almeidaraul
force-pushed
the
TO-404/4-drop-legacy-fields
branch
from
August 18, 2026 13:14
36e311d to
07f007c
Compare
Contract step of the expand/contract rolling-upgrade sequence. After the backfill + read-new release (#850) is deployed, remove the now-unused legacy solution-specific fields: - Drop `artefact.bundled_builds_hash` column - Drop the `artefact_bundled_builds_association` table - Swap the `unique_solution` index to a simple (name, version) uniqueness - Reset the transitional `alembic check` expand/contract exclusions in env.py now that the ORM and DB schema agree again Migration `8bd1f5009f02` revises the backfill migration `d315c1f212b9`. Deploy only after #850 has merged and rolled out. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
almeidaraul
force-pushed
the
TO-404/4-drop-legacy-fields
branch
from
August 18, 2026 14:14
07f007c to
96424b7
Compare
almeidaraul
marked this pull request as ready for review
August 18, 2026 15:07
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the contract step of the TO-404 expand/contract sequence by removing legacy, solution-specific bundled-build schema elements now that artefact.attributes is the source of truth. This keeps the ORM and DB schema aligned again (including alembic check) and tightens solution uniqueness to (name, version).
Changes:
- Add destructive Alembic migration
8bd1f5009f02to dropartefact.bundled_builds_hashandartefact_bundled_builds_association, and swapunique_solutionto(name, version). - Remove transitional
alembic checkexpand/contract ignore lists inbackend/migrations/env.py. - Add/extend tests covering the contract migration and the updated solution uniqueness constraint.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/migrations/versions/2026_08_10_1716-8bd1f5009f02_drop_solution_specific_bundled_build_fields.py | Contract migration: swap unique_solution, re-run backfill, then drop legacy column/table. |
| backend/migrations/env.py | Reset expand/contract alembic check ignore sets now that schema and ORM match. |
| backend/tests/migrations/test_8bd1f5009f02_drop_solution_specific_bundled_build_fields.py | New migration-level upgrade/downgrade/guard tests for the contract revision. |
| backend/tests/data_access/test_models.py | Add uniqueness tests asserting solutions are unique on (name, version) regardless of source/track/stage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| conn, "solution-unknown-build", attributes='{"bundled_builds": [999999999]}' | ||
| ) | ||
|
|
||
| # Raises a DatabaseError; after guarding the traversal it should complete cleanly. |
Comment on lines
+132
to
+154
| UPDATE artefact AS a | ||
| SET attributes = a.attributes | ||
| || jsonb_strip_nulls( | ||
| jsonb_build_object('bundled_builds_hash', a.bundled_builds_hash) | ||
| ) | ||
| || COALESCE( | ||
| ( | ||
| SELECT jsonb_build_object( | ||
| 'bundled_builds', | ||
| jsonb_agg(assoc.artefact_build_id ORDER BY assoc.artefact_build_id) | ||
| ) | ||
| FROM artefact_bundled_builds_association assoc | ||
| WHERE assoc.artefact_id = a.id | ||
| HAVING count(*) > 0 | ||
| ), | ||
| '{}'::jsonb | ||
| ) | ||
| WHERE a.bundled_builds_hash IS NOT NULL | ||
| OR EXISTS ( | ||
| SELECT 1 | ||
| FROM artefact_bundled_builds_association assoc | ||
| WHERE assoc.artefact_id = a.id | ||
| ) |
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.
Stack
This is PR 4 of 4 in the TO-404 expand/contract split. Deploy in order — each PR must be merged and rolled out before the next:
attributesfield (expand)Base:
TO-404/3-migrate-read-new(#850).What this does
The contract step of the rolling-upgrade sequence. After #850 has deployed (nothing reads or writes the legacy fields anymore), this removes them:
artefact.bundled_builds_hashcolumnartefact_bundled_builds_associationtableunique_solutionindex to a simple(name, version)uniqueness constraintalembic checkexpand/contract exclusions inenv.pynow that the ORM and DB schema agree againMigration
8bd1f5009f02revises the backfill migrationd315c1f212b9.Merge and deploy only after #850 has merged and rolled out. The destructive migration includes a guard (
_assert_no_duplicate_solutions) that refuses to run if duplicate solutions exist under the new(name, version)uniqueness — resolve any duplicates first.Testing
alembic upgrade head+alembic checkclean on a fresh DB (ORM matches schema)ruff/mypypass