Skip to content

Commit

Permalink
Add SQL migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn committed Oct 10, 2023
1 parent 2c12eac commit 0af9844
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/src/database/mod.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ impl Driver {
.port(options.port);

let pool = MySqlPool::connect_with(opts).await?;

sqlx::query(include_str!("skins.sql"))
.execute(&mut *pool.acquire().await?)
.await?;

Ok(Self::Mysql(pool))
}

Expand All @@ -77,13 +82,23 @@ impl Driver {
.port(options.port);

let pool = PgPool::connect_with(opts).await?;
sqlx::query(include_str!("skins.sql"))
.execute(&mut *pool.acquire().await?)
.await?;


Ok(Self::Postgres(pool))
}

async fn new_sqlite(path: &Path) -> Result<Self, sqlx::Error> {
let opts = SqliteConnectOptions::new().filename(path);

let pool = SqlitePool::connect_with(opts).await?;
sqlx::query(include_str!("skins.sql"))
.execute(&mut *pool.acquire().await?)
.await?;


Ok(Self::Sqlite(pool))
}

Expand Down
Empty file modified lib/src/database/profile.rs
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions lib/src/database/skins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE skins (
uuid TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
signature TEXT NOT NULL
);

0 comments on commit 0af9844

Please sign in to comment.