From 35fbc2761ea6fde22df2785e71fdd6a473ab29f9 Mon Sep 17 00:00:00 2001 From: kexkey Date: Tue, 14 Dec 2021 20:50:08 -0500 Subject: [PATCH] Fixes in pg migration and computer's speed --- .../templates/installer/start.sh | 4 ++-- .../templates/installer/stop.sh | 2 +- .../templates/installer/testdeployment.sh | 2 +- proxy_docker/app/data/cyphernode.postgresql | 6 ++--- .../data/sqlmigrate20211105_0.7.0-0.8.0.sh | 23 ++++++++++--------- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/cyphernodeconf_docker/templates/installer/start.sh b/cyphernodeconf_docker/templates/installer/start.sh index aed65c6..647cab4 100644 --- a/cyphernodeconf_docker/templates/installer/start.sh +++ b/cyphernodeconf_docker/templates/installer/start.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash . ./.cyphernodeconf/installer/config.sh @@ -73,7 +73,7 @@ start_apps printf "\r\nDetermining the speed of your machine..." speedseconds=$(bash -c ' : {1..500000} ; echo $SECONDS') -if [[ $speedseconds > 2 ]]; then +if [ "${speedseconds}" -gt "2" ]; then printf "\r\n\033[1;31mSince we're on a slow computer, let's give Docker 60 more seconds before performing our tests...\033[0m\r\n\r\n" sleep 60 else diff --git a/cyphernodeconf_docker/templates/installer/stop.sh b/cyphernodeconf_docker/templates/installer/stop.sh index 9ac13ab..6096e57 100644 --- a/cyphernodeconf_docker/templates/installer/stop.sh +++ b/cyphernodeconf_docker/templates/installer/stop.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash current_path="$(cd "$(dirname "$0")" >/dev/null && pwd)" diff --git a/cyphernodeconf_docker/templates/installer/testdeployment.sh b/cyphernodeconf_docker/templates/installer/testdeployment.sh index 8eec117..2cfa327 100644 --- a/cyphernodeconf_docker/templates/installer/testdeployment.sh +++ b/cyphernodeconf_docker/templates/installer/testdeployment.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash . ./.cyphernodeconf/installer/config.sh diff --git a/proxy_docker/app/data/cyphernode.postgresql b/proxy_docker/app/data/cyphernode.postgresql index 1b11603..32dc4e9 100644 --- a/proxy_docker/app/data/cyphernode.postgresql +++ b/proxy_docker/app/data/cyphernode.postgresql @@ -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, diff --git a/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh b/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh index 8c8e9ad..68990f2 100644 --- a/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh +++ b/proxy_docker/app/data/sqlmigrate20211105_0.7.0-0.8.0.sh @@ -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