summaryrefslogtreecommitdiffstats
path: root/src/db/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/mod.rs')
-rw-r--r--src/db/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs
new file mode 100644
index 0000000..97a5b25
--- /dev/null
+++ b/src/db/mod.rs
@@ -0,0 +1,20 @@
+use sqlx::{postgres::PgPoolOptions, Pool, Postgres};
+
+mod artworks;
+
+#[derive(Clone)]
+pub struct Database(Pool<Postgres>);
+
+impl Database {
+ pub async fn new(connection_string: &str) -> Self {
+ let pool = PgPoolOptions::new()
+ .max_connections(5)
+ .connect(connection_string)
+ .await
+ .unwrap();
+
+ sqlx::migrate!("./migrations").run(&pool).await.unwrap();
+
+ Self(pool)
+ }
+}