diff options
author | 2024-11-13 20:00:15 +0000 | |
---|---|---|
committer | 2024-11-13 20:00:15 +0000 | |
commit | b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6 (patch) | |
tree | 280a31f5887aafdaa200a2b5f4c05ff106d9e365 /src/db | |
download | critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.tar.gz critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.tar.bz2 critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.zip |
initial commit
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/artworks.rs | 1 | ||||
-rw-r--r-- | src/db/mod.rs | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/db/artworks.rs b/src/db/artworks.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/db/artworks.rs @@ -0,0 +1 @@ + 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) + } +} |