From 7081c76e60853cf09f3af4403661bbcef2a2ed15 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sat, 29 Jul 2023 21:32:16 +0100 Subject: [PATCH] feat: setup table used for new accounts --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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 (