"
}
+pub(crate) async fn upgrade_db(schema: i32, client: &mut tokio_postgres::Client) {
+ match schema {
+ SCHEMA_VERSION => {},
+ _ => panic!("Unknown schema in db: {}, we support up to {}", schema, SCHEMA_VERSION),
+ }
+}
+
/// EDIT ME
pub(crate) fn ln_peers() -> Vec<(PublicKey, SocketAddr)> {
vec![
pub(crate) async fn persist_gossip(&mut self) {
let connection_config = config::db_connection_config();
- let (client, connection) =
+ let (mut client, connection) =
connection_config.connect(NoTls).await.unwrap();
tokio::spawn(async move {
panic!("db init error: {}", initialization_error);
}
+ let cur_schema = client.query("SELECT db_schema FROM config WHERE id = $1", &[&1]).await.unwrap();
+ if !cur_schema.is_empty() {
+ config::upgrade_db(cur_schema[0].get(0), &mut client).await;
+ }
+
let initialization = client
.execute(
// TODO: figure out a way to fix the id value without Postgres complaining about