db: adds a state_change history to database

This commit is contained in:
Michael Schmoock
2020-10-28 11:46:22 +01:00
committed by neil saitug
parent 68ce25c92d
commit 88c1dc56e8
8 changed files with 179 additions and 89 deletions

View File

@@ -842,6 +842,12 @@ struct db_query db_postgres_queries[] = {
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
.query = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = $1",
@@ -1244,6 +1250,12 @@ struct db_query db_postgres_queries[] = {
.placeholders = 2,
.readonly = false,
},
{
.name = "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES (?, ?, ?, ?, ?, ?);",
.query = "INSERT INTO channel_state_changes ( channel_id, timestamp, old_state, new_state, cause, message) VALUES ($1, $2, $3, $4, $5, $6);",
.placeholders = 6,
.readonly = false,
},
{
.name = "SELECT id FROM peers WHERE node_id = ?",
.query = "SELECT id FROM peers WHERE node_id = $1",
@@ -1666,10 +1678,10 @@ struct db_query db_postgres_queries[] = {
},
};
#define DB_POSTGRES_QUERY_COUNT 276
#define DB_POSTGRES_QUERY_COUNT 278
#endif /* HAVE_POSTGRES */
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:5f01b4eb0c1df3e18b6d3f7af23a509d584b12b8b0a637451576d2ef80bed04f
// SHA256STAMP:9ed50e3cbb14e9bb979a6b0f8754f1cb2412a7adc032f0a71e88cd534b3828d4