From: Vladimir Fomene Date: Fri, 12 Aug 2022 13:13:00 +0000 (+0300) Subject: Add datatype for is_spent sqlite column X-Git-Tag: v0.23.0-rc.1~8^2~1 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/enum.ApplyHeaderError.html?a=commitdiff_plain;h=369e17b8012df56587c10cd9ce6651908d6a4be9;p=bdk 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. --- diff --git a/src/database/sqlite.rs b/src/database/sqlite.rs index dc35b856..c875bd94 100644 --- a/src/database/sqlite.rs +++ b/src/database/sqlite.rs @@ -52,7 +52,14 @@ static MIGRATIONS: &[&str] = &[ "DELETE FROM transactions;", "DELETE FROM utxos;", "DROP INDEX idx_txid_vout;", - "CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);" + "CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);", + "BEGIN TRANSACTION;\ + ALTER TABLE utxos RENAME TO utxos_old;\ + CREATE TABLE utxos (value INTEGER, keychain TEXT, vout INTEGER, txid BLOB, script BLOB, is_spent BOOLEAN DEFAULT 0);\ + INSERT INTO utxos SELECT value, keychain, vout, txid, script, is_spent FROM utxos_old;\ + DROP TABLE utxos_old;\ + CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);\ + COMMIT;" ]; /// Sqlite database stored on filesystem