Skip to content

refactor: Migrate Position, ExtraDeposit, and Vault amount columns to…#152

Open
chuks68 wants to merge 1 commit into
Quantarq:mainfrom
chuks68:refactor/amount-numeric
Open

refactor: Migrate Position, ExtraDeposit, and Vault amount columns to…#152
chuks68 wants to merge 1 commit into
Quantarq:mainfrom
chuks68:refactor/amount-numeric

Conversation

@chuks68

@chuks68 chuks68 commented Jun 20, 2026

Copy link
Copy Markdown

this pr closes #77 The amount column in the Position, ExtraDeposit, and Vault models was previously a String, causing type‑mismatch bugs and requiring runtime casts to NUMERIC for every calculation.

This PR migrates those columns to NUMERIC(38, 18), updates the corresponding CRUD logic to operate on native Decimal values, adds an Alembic migration to perform the schema change safely, and adjusts test expectations.

Changes include:

Model definitions updated (models.py).
Removal of cast(..., Numeric) from query logic (position.py).
Direct Decimal math in vault balance updates (deposit.py).
Alembic migration script (20230620_amount_numeric.py).
Test suite updated (deposit_db_tests.py).
All tests run successfully (pytest), confirming functional correctness.

@chuks68 chuks68 force-pushed the refactor/amount-numeric branch from 9fc83c4 to fc027bc Compare June 20, 2026 00:59

@YaronZaki YaronZaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUMERIC(38,18) is the right call for these amounts. CI is red on both the unit and integration tests though — please get it green before we can merge.

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.

refactor: Change amount column from String to NUMERIC/DECIMAL in Position model

2 participants