Skip to content

Commit ac3cdfb

Browse files
amalcaraznesitor
authored andcommitted
fix: migration bonus_amount
1 parent f544a68 commit ac3cdfb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

deployment/migrations/versions/0040_e1f2a3b4c5d6_rename_credit_history_ratio_to_price.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def upgrade() -> None:
2424
op.add_column('credit_history', sa.Column('bonus_amount', sa.BigInteger(), nullable=True))
2525

2626
# Transform data: price calculation depends on payment token
27-
# For ALEPH token: ratio = (1 / price) * (1 + 0.2), therefore price = 1.2 / ratio
27+
# Taking into account that bonus_ratio = 1.2
28+
# For ALEPH token: ratio = (1 / price) * bonus_ratio, therefore price = bonus_ratio / ratio
2829
# For other tokens: price = 1/ratio
2930
# Only update rows where payment_method is NOT 'credit_expense' or 'credit_transfer'
3031
# and where ratio is not null and not zero
@@ -44,7 +45,7 @@ def upgrade() -> None:
4445
# Update bonus_amount for ALEPH token records
4546
connection.execute(sa.text("""
4647
UPDATE credit_history
47-
SET bonus_amount = TRUNC(amount * 0.20)
48+
SET bonus_amount = TRUNC(amount / 1.2)
4849
WHERE token = 'ALEPH'
4950
AND amount IS NOT NULL
5051
"""))

0 commit comments

Comments
 (0)