From 5a0eb98f30536f8ab57cb375e9ef9af2861529c7 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 8 Aug 2023 23:19:44 +0200 Subject: [PATCH] cave/db: always call create_schema() prepared statements require them to have run --- cave/src/db.rs | 13 +++++-------- gatherer/src/main.rs | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/cave/src/db.rs b/cave/src/db.rs index 9f26b36..e0b486b 100644 --- a/cave/src/db.rs +++ b/cave/src/db.rs @@ -35,6 +35,11 @@ impl Database { } }); + for command in CREATE_SCHEMA_COMMANDS { + client.execute(*command, &[]).await + .unwrap(); + } + let add_app = client.prepare("INSERT INTO instance_apps (host, client_id, client_secret) VALUES ($1, $2, $3)") .await .unwrap(); @@ -67,14 +72,6 @@ impl Database { } } - pub async fn create_schema(&self) -> Result<(), Error> { - for command in CREATE_SCHEMA_COMMANDS { - self.inner.client.execute(*command, &[]) - .await?; - } - Ok(()) - } - pub async fn add_app(&self, host: &str, client_id: &str, client_secret: &str) -> Result<(), Error> { self.inner.client.execute(&self.inner.add_app, &[&host, &client_id, &client_secret]) .await?; diff --git a/gatherer/src/main.rs b/gatherer/src/main.rs index 067d62d..63dd688 100644 --- a/gatherer/src/main.rs +++ b/gatherer/src/main.rs @@ -28,8 +28,6 @@ async fn main() { cave::systemd::status("Connecting to database"); let db = cave::db::Database::connect(&config.database).await; - db.create_schema().await - .expect("db.create_schema"); cave::systemd::status("Starting redis client"); let store = cave::store::Store::new(8, config.redis.clone()).await;