mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-01-16 19:24:19 +01:00
Fixes in pg migration and computer's speed
This commit is contained in:
@@ -77,7 +77,7 @@ CREATE TABLE batcher (
|
||||
inserted_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
INSERT INTO batcher (id, label, conf_target, feerate) VALUES (1, 'default', 6, NULL);
|
||||
SELECT SETVAL('batcher_id_seq', 1);
|
||||
SELECT SETVAL('batcher_id_seq', 1);
|
||||
|
||||
CREATE TABLE recipient (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -110,7 +110,7 @@ CREATE TABLE watching_by_txid (
|
||||
inserted_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_watching_by_txid_txid ON watching_by_txid (txid);
|
||||
CREATE UNIQUE INDEX idx_watching_by_txid_1x ON watching_by_txid (txid, callback1conf, callbackxconf);
|
||||
CREATE UNIQUE INDEX idx_watching_by_txid_1x ON watching_by_txid (txid, COALESCE(callback1conf, ''), COALESCE(callbackxconf, ''));
|
||||
CREATE INDEX idx_watching_by_txid_watching ON watching_by_txid (watching);
|
||||
CREATE INDEX idx_watching_by_txid_callback1conf ON watching_by_txid (callback1conf);
|
||||
CREATE INDEX idx_watching_by_txid_calledback1conf ON watching_by_txid (calledback1conf);
|
||||
@@ -139,7 +139,7 @@ CREATE UNIQUE INDEX idx_cp_propval ON cyphernode_props (property, value);
|
||||
|
||||
INSERT INTO cyphernode_props (id, property, value) VALUES (1, 'version', '0.1');
|
||||
INSERT INTO cyphernode_props (id, property, value) VALUES (2, 'pay_index', '0');
|
||||
SELECT SETVAL('cyphernode_props_id_seq', 2);
|
||||
SELECT SETVAL('cyphernode_props_id_seq', 2);
|
||||
|
||||
CREATE TABLE ln_invoice (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
||||
@@ -16,9 +16,9 @@ else
|
||||
fi
|
||||
|
||||
trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] Checking if postgres is loaded/imported..."
|
||||
lastval=$(psql -qAtX -h postgres -U cyphernode -c "select last_value from pg_sequences where sequencename='cyphernode_props_id_seq'")
|
||||
version=$(psql -qAtX -h postgres -U cyphernode -c "select value from cyphernode_props where property='version'")
|
||||
returncode=$?
|
||||
if [ -z "${lastval}" ] || [ "${lastval}" -lt "2" ]; then
|
||||
if [ "${version}" != "0.2" ]; then
|
||||
# if cyphernode_props_id_seq isn't set, it's probably because database hasn't been loaded/imported yet
|
||||
trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] Extracting and converting sqlite3 data..."
|
||||
cat sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extract.sql | sqlite3 $DB_FILE
|
||||
@@ -32,15 +32,16 @@ if [ -z "${lastval}" ] || [ "${lastval}" -lt "2" ]; then
|
||||
|
||||
trace "[sqlmigrate20211105_0.7.0-0.8.0.sh] Appending postgresql sequence creation..."
|
||||
echo "
|
||||
select setval('cyphernode_props_id_seq', (SELECT MAX(id) FROM cyphernode_props));
|
||||
select setval('ln_invoice_id_seq', (SELECT MAX(id) FROM ln_invoice));
|
||||
select setval('recipient_id_seq', (SELECT MAX(id) FROM recipient));
|
||||
select setval('stamp_id_seq', (SELECT MAX(id) FROM stamp));
|
||||
select setval('tx_id_seq', (SELECT MAX(id) FROM tx));
|
||||
select setval('watching_by_pub32_id_seq', (SELECT MAX(id) FROM watching_by_pub32));
|
||||
select setval('watching_by_txid_id_seq', (SELECT MAX(id) FROM watching_by_txid));
|
||||
select setval('watching_id_seq', (SELECT MAX(id) FROM watching));
|
||||
select setval('batcher_id_seq', (SELECT MAX(id) FROM batcher));
|
||||
select setval('cyphernode_props_id_seq', (SELECT MAX(id) FROM cyphernode_props));
|
||||
select setval('ln_invoice_id_seq', (SELECT MAX(id) FROM ln_invoice));
|
||||
select setval('recipient_id_seq', (SELECT MAX(id) FROM recipient));
|
||||
select setval('stamp_id_seq', (SELECT MAX(id) FROM stamp));
|
||||
select setval('tx_id_seq', (SELECT MAX(id) FROM tx));
|
||||
select setval('watching_by_pub32_id_seq', (SELECT MAX(id) FROM watching_by_pub32));
|
||||
select setval('watching_by_txid_id_seq', (SELECT MAX(id) FROM watching_by_txid));
|
||||
select setval('watching_id_seq', (SELECT MAX(id) FROM watching));
|
||||
select setval('batcher_id_seq', (SELECT MAX(id) FROM batcher));
|
||||
update cyphernode_props set value='0.2' where property='version';
|
||||
commit;
|
||||
" >> ${DB_PATH}/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
|
||||
|
||||
|
||||
Reference in New Issue
Block a user