From 0af9844bb3d9fc7179f456fdf2126ad1838b55e6 Mon Sep 17 00:00:00 2001 From: Tobias de Bruijn Date: Tue, 10 Oct 2023 02:15:28 +0200 Subject: [PATCH] Add SQL migrations --- lib/src/database/mod.rs | 15 +++++++++++++++ lib/src/database/profile.rs | 0 lib/src/database/skins.sql | 5 +++++ 3 files changed, 20 insertions(+) mode change 100644 => 100755 lib/src/database/mod.rs mode change 100644 => 100755 lib/src/database/profile.rs create mode 100644 lib/src/database/skins.sql diff --git a/lib/src/database/mod.rs b/lib/src/database/mod.rs old mode 100644 new mode 100755 index fe02de8..5f10c29 --- a/lib/src/database/mod.rs +++ b/lib/src/database/mod.rs @@ -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)) } @@ -77,6 +82,11 @@ 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)) } @@ -84,6 +94,11 @@ impl Driver { 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)) } diff --git a/lib/src/database/profile.rs b/lib/src/database/profile.rs old mode 100644 new mode 100755 diff --git a/lib/src/database/skins.sql b/lib/src/database/skins.sql new file mode 100644 index 0000000..a3efac5 --- /dev/null +++ b/lib/src/database/skins.sql @@ -0,0 +1,5 @@ +CREATE TABLE skins ( + uuid TEXT NOT NULL PRIMARY KEY, + value TEXT NOT NULL, + signature TEXT NOT NULL +); \ No newline at end of file