-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description This PR changes the type of the `id` column in the `proposed_solutions` table from `i64` to `numeric(78,0)`. This adjustment prevents potential overflow issues from `u64` values in the driver API, which could previously lead to [failed u64 -> i64 conversions](https://github.com/cowprotocol/services/blob/main/crates/autopilot/src/infra/persistence/mod.rs#L154) and errors when saving proposed solutions. Alternative approaches considered: 1. Dropping the `id` column: While feasible, this would prevent reusing the existing `domain::competition::Solution` object in the autopilot and would require either creating a new domain object or generating IDs dynamically when reading the solution from database, both of which are not great ideas. 2. Changing the API type to `u32`: A more invasive change, requiring modifications to the driver API and adjustments by solvers (e.g., Copium, which sometimes reports IDs exceeding `i64::MAX`). After evaluating these options, I chose the least disruptive solution of converting `id` to `numeric(78,0)`. # Changes <!-- List of detailed changes (how the change is accomplished) --> - [ ] Change the type of "id" column, from BigInt to numeric(78,0) ## How to test Existing tests. <!-- ## Related Issues Fixes # -->
- Loading branch information
Showing
4 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Change the type of "id" column in proposed_solutions table from bigint to text | ||
ALTER TABLE proposed_solutions | ||
ALTER COLUMN id TYPE numeric(78,0) USING id::numeric(78,0); |