diff --git a/src/lib.rs b/src/lib.rs index a87ae4b..5b3a0f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,16 @@ use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; use tide::prelude::*; +#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)] +pub struct AccountsNew { + mail: String, + auth_code: String, + date_iso: String, + date_expiry: String, + name_first: String, + name_surname: String, +} + #[derive(Debug, Deserialize, Serialize, sqlx::FromRow)] pub struct AccountsPending { user: String, @@ -54,6 +64,23 @@ pub async fn db_init(config: &Config) -> Result, Error> { .execute(&pool) .await?; + sqlx::query( + "CREATE TABLE IF NOT EXISTS accounts_new ( + mail text primary key, + auth_code text not null, + date_iso text not null, + date_expiry text not null, + name_first text not null, + name_surname integer not null + )", + ) + .execute(&pool) + .await?; + + sqlx::query("CREATE INDEX IF NOT EXISTS index_auth_code ON accounts_new (auth_code)") + .execute(&pool) + .await?; + // this is for active use sqlx::query( "CREATE TABLE IF NOT EXISTS accounts (