refactor: replace latest_checkout table primary key#1681
Merged
gustavobtflores merged 1 commit intokernelci:mainfrom Dec 16, 2025
Merged
Conversation
5f707cf to
d31295d
Compare
d31295d to
ae4b106
Compare
ae4b106 to
857aec1
Compare
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.
This PR modifies
checkout_idinlatest_checkoutto not be a primary key and introduces a surrogate primary key calledidas it is required by Django. This is done to avoid that the database throws an exception for duplicated primary key, we are already checking for duplicity with a UNIQUE constraint and the target is not thecheckout_idfield.Reasoning
This happens because we do a upsert when inserting in
latest_checkouttable, we have a query like:If we try to update a
checkout_idthat is already in the database, we will get a duplicated primary key exception, where it should just do nothing. We cannot have multiple conflict targets in a single query, so the solution is to just remove it and ensure uniqueness with the UNIQUE constraint.The UNIQUE constraint cannot be transformed in a composite primary key because it allows NULL values.
Closes #1680