status-go/walletdatabase/migrations/sql/1695932536_balance_history_v2.up.sql
IvanBelyakoff 9d6577049f
Implemented balance history based on transfers (#4022)
* feat(wallet): implement balance history based on fetched transfers
* Added vendor 'ttlcache'
2023-10-04 15:00:12 +03:00

18 lines
653 B
SQL

-- One entry per chain_id, address, currency, block
-- balance is a serialized big.Int
CREATE TABLE IF NOT EXISTS balance_history_v2 (
chain_id UNSIGNED BIGINT NOT NULL,
address VARCHAR NOT NULL,
currency VARCHAR NOT NULL,
block BIGINT NOT NULL,
timestamp INT NOT NULL,
balance BLOB
);
CREATE UNIQUE INDEX IF NOT EXISTS balance_history_identify_entry ON balance_history_v2 (chain_id, address, currency, block);
CREATE INDEX IF NOT EXISTS balance_history_filter_entries ON balance_history_v2 (chain_id, address, currency, block, timestamp);
DROP TABLE balance_history;
ALTER TABLE balance_history_v2 RENAME TO balance_history;