mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 13:14:56 +01:00
DB tweaks and fix
This commit is contained in:
@@ -11,12 +11,10 @@ CREATE TABLE watching_by_pub32 (
|
||||
watching INTEGER DEFAULT FALSE,
|
||||
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_watching_by_pub32_pub32 ON watching_by_pub32 (pub32);
|
||||
CREATE INDEX idx_watching_by_pub32_label ON watching_by_pub32 (label);
|
||||
|
||||
CREATE TABLE watching (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
address TEXT,
|
||||
address TEXT UNIQUE,
|
||||
watching INTEGER DEFAULT FALSE,
|
||||
callback0conf TEXT,
|
||||
calledback0conf INTEGER DEFAULT FALSE,
|
||||
@@ -27,7 +25,6 @@ CREATE TABLE watching (
|
||||
pub32_index INTEGER,
|
||||
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_watching_address ON watching (address);
|
||||
|
||||
CREATE TABLE watching_tx (
|
||||
watching_id INTEGER REFERENCES watching,
|
||||
@@ -79,7 +76,6 @@ CREATE TABLE stamp (
|
||||
calledback INTEGER DEFAULT FALSE,
|
||||
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_stamp_hash ON stamp (hash);
|
||||
CREATE INDEX idx_stamp_calledback ON stamp (calledback);
|
||||
|
||||
CREATE TABLE cyphernode_props (
|
||||
|
||||
@@ -11,8 +11,11 @@ CREATE TABLE watching_by_pub32 (
|
||||
watching INTEGER DEFAULT FALSE,
|
||||
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_watching_by_pub32_pub32 ON watching_by_pub32 (pub32);
|
||||
CREATE INDEX idx_watching_by_pub32_label ON watching_by_pub32 (label);
|
||||
|
||||
-- for all duplicate addresses, we only keep the last one inserted
|
||||
DELETE FROM watching WHERE id NOT IN (SELECT MAX(id) FROM watching GROUP BY address);
|
||||
DROP INDEX idx_watching_address;
|
||||
CREATE UNIQUE INDEX idx_watching_address ON watching(address);
|
||||
|
||||
ALTER TABLE watching ADD COLUMN watching_by_pub32_id INTEGER REFERENCES watching_by_pub32;
|
||||
ALTER TABLE watching ADD COLUMN pub32_index INTEGER;
|
||||
|
||||
@@ -32,7 +32,7 @@ unwatchpub32request() {
|
||||
local returncode
|
||||
trace "[unwatchpub32request] Unwatch pub32 ${pub32}"
|
||||
|
||||
id=$(sql "SELECT id FROM watching WHERE pub32='${pub32}'")
|
||||
id=$(sql "SELECT id FROM watching_by_pub32 WHERE pub32='${pub32}'")
|
||||
trace "[unwatchpub32request] id: ${id}"
|
||||
|
||||
sql "UPDATE watching_by_pub32 SET watching=0 WHERE id=${id}"
|
||||
|
||||
Reference in New Issue
Block a user