[Database] Add 'creation_datetime' to User + some little things

This commit is contained in:
Greg Burri 2025-01-07 23:55:16 +01:00
parent 91ab379718
commit 7a09e2360e
14 changed files with 179 additions and 131 deletions

View file

@ -628,14 +628,15 @@ mod tests {
sqlx::query(
r#"
INSERT INTO [User]
([id], [email], [name], [password], [validation_token_datetime], [validation_token])
([id], [email], [name], [creation_datetime], [password], [validation_token_datetime], [validation_token])
VALUES
($1, $2, $3, $4, $5, $6)
($1, $2, $3, $4, $5, $6, $7)
"#
)
.bind(user_id)
.bind("paul@atreides.com")
.bind("paul")
.bind("")
.bind("$argon2id$v=19$m=4096,t=3,p=1$G4fjepS05MkRbTqEImUdYg$GGziE8uVQe1L1oFHk37lBno10g4VISnVqynSkLCH3Lc")
.bind("2022-11-29 22:05:04.121407300+00:00")
.bind(None::<&str>) // 'null'.

View file

@ -222,11 +222,12 @@ WHERE [id] = $1
sqlx::query(
r#"
INSERT INTO [User]
([email], [validation_token], [validation_token_datetime], [password])
VALUES ($1, $2, $3, $4)
([email], [creation_datetime], [validation_token], [validation_token_datetime], [password])
VALUES ($1, $2, $3, $4, $5)
"#,
)
.bind(email)
.bind(Utc::now())
.bind(&token)
.bind(datetime)
.bind(hashed_password)
@ -509,11 +510,12 @@ mod tests {
sqlx::query(
r#"
INSERT INTO
[User] ([id], [email], [name], [password], [validation_token_datetime], [validation_token])
[User] ([id], [email], [name], [creation_datetime], [password], [validation_token_datetime], [validation_token])
VALUES (
1,
'paul@atreides.com',
'paul',
'',
'$argon2id$v=19$m=4096,t=3,p=1$1vtXcacYjUHZxMrN6b2Xng$wW8Z59MIoMcsIljnjHmxn3EBcc5ymEySZPUVXHlRxcY',
0,
NULL
@ -557,10 +559,11 @@ INSERT INTO
sqlx::query(
r#"
INSERT INTO [User]
([id], [email], [name], [password], [validation_token_datetime], [validation_token])
([id], [email], [creation_datetime], [name], [password], [validation_token_datetime], [validation_token])
VALUES (
1,
'paul@atreides.com',
'',
'paul',
'$argon2id$v=19$m=4096,t=3,p=1$1vtXcacYjUHZxMrN6b2Xng$wW8Z59MIoMcsIljnjHmxn3EBcc5ymEySZPUVXHlRxcY',
0,
@ -896,17 +899,11 @@ VALUES (
sqlx::query(
r#"
INSERT INTO [User]
([id], [email], [name], [password], [validation_token_datetime], [validation_token])
([id], [email], [name], [creation_datetime], [password], [validation_token_datetime], [validation_token])
VALUES
($1, $2, $3, $4, $5, $6)
(1, 'paul@atreides.com', 'paul', '', '$argon2id$v=19$m=4096,t=3,p=1$G4fjepS05MkRbTqEImUdYg$GGziE8uVQe1L1oFHk37lBno10g4VISnVqynSkLCH3Lc', '2022-11-29 22:05:04.121407300+00:00', NULL)
"#
)
.bind(1)
.bind("paul@atreides.com")
.bind("paul")
.bind("$argon2id$v=19$m=4096,t=3,p=1$G4fjepS05MkRbTqEImUdYg$GGziE8uVQe1L1oFHk37lBno10g4VISnVqynSkLCH3Lc")
.bind("2022-11-29 22:05:04.121407300+00:00")
.bind(None::<&str>) // 'null'.
).await?;
let user = connection.load_user(1).await?.unwrap();