cave/db: always call create_schema()

prepared statements require them to have run
This commit is contained in:
Astro 2023-08-08 23:19:44 +02:00
parent 9ede54b384
commit 5a0eb98f30
2 changed files with 5 additions and 10 deletions

View File

@ -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?;

View File

@ -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;