From b5fcddcf1ab795b96481f3e46da9356e4f9c8b41 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Tue, 29 Nov 2022 07:20:49 -0800 Subject: [PATCH] Add sqlite migration to drop duplicated script_pubkeys rows --- src/database/sqlite.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/database/sqlite.rs b/src/database/sqlite.rs index e837b6c4c..9bcfca832 100644 --- a/src/database/sqlite.rs +++ b/src/database/sqlite.rs @@ -59,8 +59,15 @@ static MIGRATIONS: &[&str] = &[ "DROP TABLE utxos_old;", "CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);", // Fix issue https://github.com/bitcoindevkit/bdk/issues/801: drop duplicated script_pubkeys - // TODO "", + "ALTER TABLE script_pubkeys RENAME TO script_pubkeys_old;", + "DROP INDEX idx_keychain_child;", + "DROP INDEX idx_script;", + "CREATE TABLE script_pubkeys (keychain TEXT, child INTEGER, script BLOB);", + "CREATE INDEX idx_keychain_child ON script_pubkeys(keychain, child);", + "CREATE INDEX idx_script ON script_pubkeys(script);", "CREATE UNIQUE INDEX idx_script_pks_unique ON script_pubkeys(keychain, child);", + "INSERT OR REPLACE INTO script_pubkeys SELECT keychain, child, script FROM script_pubkeys_old;", + "DROP TABLE script_pubkeys_old;" ]; /// Sqlite database stored on filesystem