feat: add a new col and populate it

This commit is contained in:
silver 2025-03-11 00:02:15 +00:00
parent f193bb5ee9
commit 6510696851
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
3 changed files with 18 additions and 2 deletions

16
db/2_wolves-id.sql Normal file
View file

@ -0,0 +1,16 @@
-- add a col for the wolves ID
ALTER TABLE accounts ADD COLUMN id_wolves integer DEFAULT 0;
-- fill in the values
UPDATE accounts
SET id_wolves=(
SELECT id_wolves
FROM accounts_wolves
WHERE accounts.mail=accounts_wolves.email
)
WHERE (
SELECT id_wolves
FROM accounts_wolves
WHERE accounts.mail=accounts_wolves.email
) IS NOT NULL

View file

@ -55,6 +55,7 @@ async fn update_ldap(config: &Config, db: &Pool<Sqlite>) {
mail: "".to_string(),
student_id: "".to_string(),
secure: false,
id_wolves: 0,
};
// pull out the required info

View file

@ -57,12 +57,11 @@ pub struct Accounts {
pub mail: String,
pub student_id: String,
pub secure: bool,
pub id_wolves: i64,
}
pub async fn db_init(config: &Config) -> Result<Pool<Sqlite>, Error> {
dbg!(config);
let database = format!("{}/{}", &config.home, &config.database);
dbg!(&database);
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect_with(