epoch times and msatoshi must be bigints

This commit is contained in:
kexkey
2021-11-22 13:21:57 -05:00
parent 2e2f5329a7
commit 9bfdfa0008
3 changed files with 22 additions and 16 deletions

View File

@@ -39,15 +39,15 @@ CREATE TABLE tx (
txid VARCHAR UNIQUE,
hash VARCHAR UNIQUE,
confirmations INTEGER DEFAULT 0,
timereceived INTEGER,
timereceived BIGINT,
fee REAL,
size INTEGER,
vsize INTEGER,
is_replaceable BOOLEAN,
blockhash VARCHAR,
blockheight INTEGER,
blocktime INTEGER,
conf_target INTEGER,
blocktime BIGINT,
conf_target SMALLINT,
inserted_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_tx_timereceived ON tx (timereceived);
@@ -72,7 +72,7 @@ CREATE INDEX idx_watching_tx_tx_id ON watching_tx (tx_id);
CREATE TABLE batcher (
id SERIAL PRIMARY KEY,
label VARCHAR UNIQUE,
conf_target INTEGER,
conf_target SMALLINT,
feerate REAL,
inserted_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
@@ -144,13 +144,13 @@ CREATE TABLE ln_invoice (
label VARCHAR UNIQUE,
bolt11 VARCHAR UNIQUE,
payment_hash VARCHAR,
msatoshi INTEGER,
msatoshi BIGINT,
status VARCHAR,
pay_index INTEGER,
msatoshi_received INTEGER,
paid_at INTEGER,
msatoshi_received BIGINT,
paid_at BIGINT,
description VARCHAR,
expires_at INTEGER,
expires_at BIGINT,
callback_url VARCHAR,
calledback BOOLEAN DEFAULT FALSE,
callback_failed BOOLEAN DEFAULT FALSE,

View File

@@ -1,5 +1,6 @@
#!/bin/sh
date
echo "Waiting for postgres to be ready..."
(while true ; do psql -h postgres -U cyphernode -c "select 1;" ; [ "$?" -eq "0" ] && break ; sleep 10; done) &
wait
@@ -11,10 +12,14 @@ if [ "$?" -eq "1" ]; then
echo "Creating postgres database..."
psql -h postgres -f cyphernode.postgresql -U cyphernode
date
echo "Extracting and converting sqlite3 data..."
date
cat sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extract.sql | sqlite3 $DB_FILE
sed -ie 's/^\(INSERT.*\);$/\1 ON CONFLICT DO NOTHING;/g' sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
mv sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql ${DB_PATH}/
sed -ie 's/^\(INSERT.*\);$/\1 ON CONFLICT DO NOTHING;/g' ${DB_PATH}/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
date
echo "...appending postgresql sequences..."
echo "
select setval('cyphernode_props_id_seq', (SELECT MAX(id) FROM cyphernode_props));
@@ -27,10 +32,12 @@ if [ "$?" -eq "1" ]; then
select setval('watching_id_seq', (SELECT MAX(id) FROM watching));
select setval('batcher_id_seq', (SELECT MAX(id) FROM batcher));
commit;
" >> sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
" >> ${DB_PATH}/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql
date
echo "Importing sqlite3 data into postgresql..."
psql -h postgres -f sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql -U cyphernode
psql -h postgres -f ${DB_PATH}/sqlmigrate20211105_0.7.0-0.8.0_sqlite3-extracted-data.sql -U cyphernode
date
else
echo "New indexes migration already done, skipping!"
fi