diff --git a/migrations/mysql/20220504184155_fix_net_asset_column.sql b/migrations/mysql/20220504184155_fix_net_asset_column.sql index 8c7e89541..2d5a9d271 100644 --- a/migrations/mysql/20220504184155_fix_net_asset_column.sql +++ b/migrations/mysql/20220504184155_fix_net_asset_column.sql @@ -2,8 +2,8 @@ -- +begin ALTER TABLE `nav_history_details` MODIFY COLUMN `net_asset` DECIMAL(32, 8) DEFAULT 0.00000000 NOT NULL, - MODIFY COLUMN `balance_in_usd` DECIMAL(32, 2) DEFAULT 0.00000000 NOT NULL, - MODIFY COLUMN `balance_in_btc` DECIMAL(32, 20) DEFAULT 0.00000000 NOT NULL; + CHANGE COLUMN `balance_in_usd` `net_asset_in_usd` DECIMAL(32, 2) DEFAULT 0.00000000 NOT NULL, + CHANGE COLUMN `balance_in_btc` `net_asset_in_btc` DECIMAL(32, 20) DEFAULT 0.00000000 NOT NULL; -- +end -- +begin diff --git a/migrations/sqlite3/20211211034818_add_nav_history_details.sql b/migrations/sqlite3/20211211034818_add_nav_history_details.sql index 60707c20e..56860040c 100644 --- a/migrations/sqlite3/20211211034818_add_nav_history_details.sql +++ b/migrations/sqlite3/20211211034818_add_nav_history_details.sql @@ -2,16 +2,16 @@ -- +begin CREATE TABLE `nav_history_details` ( - gid bigint unsigned auto_increment PRIMARY KEY, - `exchange` VARCHAR NOT NULL DEFAULT '', - `subaccount` VARCHAR NOT NULL DEFAULT '', - time DATETIME(3) NOT NULL DEFAULT (strftime('%s', 'now')), - currency VARCHAR NOT NULL, - balance_in_usd DECIMAL DEFAULT 0.00000000 NOT NULL, - balance_in_btc DECIMAL DEFAULT 0.00000000 NOT NULL, - balance DECIMAL DEFAULT 0.00000000 NOT NULL, - available DECIMAL DEFAULT 0.00000000 NOT NULL, - locked DECIMAL DEFAULT 0.00000000 NOT NULL + `gid` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + `exchange` VARCHAR(30) NOT NULL DEFAULT '', + `subaccount` VARCHAR(30) NOT NULL DEFAULT '', + `time` DATETIME(3) NOT NULL DEFAULT (strftime('%s', 'now')), + `currency` VARCHAR(30) NOT NULL, + `net_asset_in_usd` DECIMAL DEFAULT 0.00000000 NOT NULL, + `net_asset_in_btc` DECIMAL DEFAULT 0.00000000 NOT NULL, + `balance` DECIMAL DEFAULT 0.00000000 NOT NULL, + `available` DECIMAL DEFAULT 0.00000000 NOT NULL, + `locked` DECIMAL DEFAULT 0.00000000 NOT NULL ); -- +end -- +begin diff --git a/pkg/service/account.go b/pkg/service/account.go index d64cdc176..2c599ca08 100644 --- a/pkg/service/account.go +++ b/pkg/service/account.go @@ -31,8 +31,8 @@ func (s *AccountService) InsertAsset(time time.Time, session string, name types. subaccount, time, currency, - balance_in_usd, - balance_in_btc, + net_asset_in_usd, + net_asset_in_btc, balance, available, locked, diff --git a/pkg/types/asset.go b/pkg/types/asset.go index 13c34b5a7..76737744c 100644 --- a/pkg/types/asset.go +++ b/pkg/types/asset.go @@ -11,15 +11,21 @@ import ( ) type Asset struct { - Currency string `json:"currency" db:"currency"` - Total fixedpoint.Value `json:"total" db:"total"` - InUSD fixedpoint.Value `json:"inUSD" db:"in_usd"` - InBTC fixedpoint.Value `json:"inBTC" db:"in_btc"` + Currency string `json:"currency" db:"currency"` + Total fixedpoint.Value `json:"total" db:"total"` + + NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"` + + // InUSD is net asset in USD + InUSD fixedpoint.Value `json:"inUSD" db:"net_asset_in_usd"` + + // InBTC is net asset in BTC + InBTC fixedpoint.Value `json:"inBTC" db:"net_asset_in_btc"` + Time time.Time `json:"time" db:"time"` Locked fixedpoint.Value `json:"lock" db:"lock" ` Available fixedpoint.Value `json:"available" db:"available"` Borrowed fixedpoint.Value `json:"borrowed" db:"borrowed"` - NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"` PriceInUSD fixedpoint.Value `json:"priceInUSD" db:"price_in_usd"` }