Skip to content

Commit 624fe98

Browse files
Add datatype for is_spent sqlite column
Although, Sqlite column accepts values of any type, it is important to annotate this column to make it easy to reason about.
1 parent 9f9ffd0 commit 624fe98

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/database/sqlite.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ static MIGRATIONS: &[&str] = &[
4343
"INSERT INTO transaction_details SELECT txid, timestamp, received, sent, fee, height FROM transaction_details_old;",
4444
"DROP TABLE transaction_details_old;",
4545
"ALTER TABLE utxos ADD COLUMN is_spent;",
46+
"ALTER TABLE utxos RENAME TO utxos_old;",
47+
"CREATE TABLE utxos (value INTEGER, keychain TEXT, vout INTEGER, txid BLOB, script BLOB, is_spent BOOLEAN DEFAULT 0);",
48+
"INSERT INTO utxos SELECT value, keychain, vout, txid, script, is_spent FROM utxos_old;",
49+
"DROP TABLE utxos_old;",
4650
// drop all data due to possible inconsistencies with duplicate utxos, re-sync required
4751
"DELETE FROM checksums;",
4852
"DELETE FROM last_derivation_indices;",
@@ -51,7 +55,6 @@ static MIGRATIONS: &[&str] = &[
5155
"DELETE FROM transaction_details;",
5256
"DELETE FROM transactions;",
5357
"DELETE FROM utxos;",
54-
"DROP INDEX idx_txid_vout;",
5558
"CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);"
5659
];
5760

0 commit comments

Comments
 (0)