Skip to content

Commit

Permalink
add chain id to nft balance lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Aug 8, 2023
1 parent cfdc095 commit 33bdb41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE `nft_balances` ADD INDEX `address_contract_address_token_id_and_chain_id_index` (`address`, `contract_address`, `token_id`, `chain_id`);

-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP INDEX address_contract_address_token_id_and_chain_id_index on nft_balances;
-- +goose StatementEnd
2 changes: 2 additions & 0 deletions packages/eventindexer/repo/nft_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (r *NFTBalanceRepository) IncreaseBalance(
Where("contract_address = ?", opts.ContractAddress).
Where("token_id = ?", opts.TokenID).
Where("address = ?", opts.Address).
Where("chain_id = ?", opts.ChainID).
First(b).
Error
if err != nil {
Expand Down Expand Up @@ -80,6 +81,7 @@ func (r *NFTBalanceRepository) SubtractBalance(
Where("contract_address = ?", opts.ContractAddress).
Where("token_id = ?", opts.TokenID).
Where("address = ?", opts.Address).
Where("chain_id = ?", opts.ChainID).
First(b).
Error
if err != nil {
Expand Down

0 comments on commit 33bdb41

Please sign in to comment.