feat: setup table used for new accounts
This commit is contained in:
parent
2f27597525
commit
7081c76e60
1 changed files with 27 additions and 0 deletions
27
src/lib.rs
27
src/lib.rs
|
@ -8,6 +8,16 @@ use std::str::FromStr;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use tide::prelude::*;
|
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)]
|
#[derive(Debug, Deserialize, Serialize, sqlx::FromRow)]
|
||||||
pub struct AccountsPending {
|
pub struct AccountsPending {
|
||||||
user: String,
|
user: String,
|
||||||
|
@ -54,6 +64,23 @@ pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
|
||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await?;
|
.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
|
// this is for active use
|
||||||
sqlx::query(
|
sqlx::query(
|
||||||
"CREATE TABLE IF NOT EXISTS accounts (
|
"CREATE TABLE IF NOT EXISTS accounts (
|
||||||
|
|
Loading…
Reference in a new issue