Skip to content

Commit

Permalink
server: Allow to update available coins even if the row is not here
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC committed Jul 8, 2019
1 parent 0dcbce0 commit 1e2b5f0
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class AggregatedAmountPostgresDAO {
def updateAvailableCoins(delta: BigDecimal)(implicit conn: Connection): Unit = {
val affectedRows = SQL(
"""
|UPDATE aggregated_amounts
|SET value = value + {delta}
|WHERE name = 'available_coins'
|INSERT INTO aggregated_amounts (name, value)
|VALUES ('available_coins', {delta})
|ON CONFLICT (name) DO
|UPDATE SET value = aggregated_amounts.value + EXCLUDED.value
""".stripMargin
).on(
'delta -> delta
Expand Down

0 comments on commit 1e2b5f0

Please sign in to comment.