From af8543c3bfec1bd141f2b61268f8f74d3bc60443 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 18 Jun 2023 16:36:23 -0700 Subject: [PATCH] some defaults are needed maybe? --- web3_proxy/src/frontend/authorization.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web3_proxy/src/frontend/authorization.rs b/web3_proxy/src/frontend/authorization.rs index 99c70625..85e49404 100644 --- a/web3_proxy/src/frontend/authorization.rs +++ b/web3_proxy/src/frontend/authorization.rs @@ -25,7 +25,7 @@ use ipnet::IpNet; use log::{error, trace, warn}; use migration::sea_orm::prelude::Decimal; use migration::sea_orm::{self, ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter}; -use migration::OnConflict; +use migration::{Expr, OnConflict}; use parking_lot::RwLock; use rdkafka::message::{Header as KafkaHeader, OwnedHeaders as KafkaOwnedHeaders, OwnedMessage}; use rdkafka::producer::{FutureProducer, FutureRecord}; @@ -1212,12 +1212,20 @@ impl Web3ProxyApp { self.db_conn().web3_context("Getting database connection")?; let balance_entry = balance::ActiveModel { + id: sea_orm::NotSet, user_id: sea_orm::Set(user_id), ..Default::default() }; balance::Entity::insert(balance_entry) - .on_conflict(OnConflict::new().to_owned()) + .on_conflict( + OnConflict::new() + .values([( + balance::Column::TotalDeposits, + Expr::col(balance::Column::TotalDeposits).add(0), + )]) + .to_owned(), + ) .exec(&db_conn) .await?;