feat: setup table used for new accounts

This commit is contained in:
silver 2023-07-29 21:32:16 +01:00
parent 2f27597525
commit 7081c76e60

View file

@ -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<Pool<Sqlite>, 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 (