diff --git a/.env b/.env
index baf06ba..eabc9e2 100644
--- a/.env
+++ b/.env
@@ -1 +1 @@
-DATABASE_URL="mysql://nerdcult_api:test@localhost/NC_Accounts"
\ No newline at end of file
+DATABASE_URL="postgres://postgres:postgres@localhost/test-db"
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 1c4c33a..c6bc59c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ env_logger = "0.10"
log = "0.4"
clap = { version = "4.3.21", features = ["derive"] }
actix-web-httpauth = "0.8.0"
-sqlx = { version = "0.7.1", features = ["runtime-tokio", "mysql", "chrono"] }
+sqlx = { version = "0.7.1", features = ["runtime-tokio", "postgres", "chrono"] }
uuid = { version = "1.4.1", features = ["v4"] }
chrono = "0.4"
mail-send = "0.4.0"
diff --git a/src/accounts.rs b/src/accounts.rs
index f6f2d39..cda26f7 100644
--- a/src/accounts.rs
+++ b/src/accounts.rs
@@ -3,11 +3,11 @@ use pbkdf2::{
password_hash::{rand_core::OsRng, PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
Pbkdf2,
};
-use sqlx::{mysql::MySqlPool, types::chrono as sqlx_chrono};
+use sqlx::{postgres::PgPool, types::chrono as sqlx_chrono};
#[derive(Debug)]
pub struct Account {
- pub id: u64,
+ pub id: i64,
pub username: String,
pub email: String,
pub salt: String,
@@ -19,7 +19,7 @@ pub struct Account {
impl Account {
/// This doesn't check if an account with that name is already existing!
pub async fn new(
- pool: &MySqlPool,
+ pool: &PgPool,
username: &String,
email: &String,
password: &String,
@@ -33,7 +33,7 @@ impl Account {
let joined = sqlx_chrono::Utc::now().naive_utc();
sqlx::query!(
- r#"INSERT INTO Accounts (username, email, salt, password, joined, verified) VALUES (?, ?, ?, ?, ?, false);"#,
+ r#"INSERT INTO Accounts (username, email, salt, password, joined, verified) VALUES ($1, $2, $3, $4, $5, false);"#,
username,
email,
salt.to_string(),
@@ -51,10 +51,10 @@ impl Account {
}
}
- pub async fn from_username(pool: &MySqlPool, username: &String) -> Result