db(T0): schema + migration 001 — super_oauth_id, firstname, lastname

tech-lead: overflow granted — gate migration avant Sprint B+C SuperOAuth
This commit is contained in:
2026-03-15 18:11:42 +01:00
parent e0bd6a2c4b
commit c414cf2d07
3 changed files with 41 additions and 8 deletions

View File

@@ -7,16 +7,32 @@ class UserManager extends AbstractManager {
// The C of CRUD - Create operation
async create(user) {
const { nickname, mail, tetardcoin, password } = user;
const { nickname, mail, tetardcoin, password, firstname, lastname } = user;
const [result] = await this.database.query(
`INSERT INTO ${this.table} (nickname, mail, tetardcoin, password) VALUES (?, ?, ?, ?)`,
[nickname, mail, tetardcoin, password]
`INSERT INTO ${this.table} (nickname, mail, tetardcoin, password, firstname, lastname) VALUES (?, ?, ?, ?, ?, ?)`,
[nickname, mail, tetardcoin, password, firstname ?? null, lastname ?? null]
);
return result.insertId;
}
async getBySuperOAuthId(superOAuthId) {
const [rows] = await this.database.query(
`SELECT * FROM ${this.table} WHERE super_oauth_id = ?`,
[superOAuthId]
);
return rows[0] ?? null;
}
async linkSuperOAuth(id, superOAuthId) {
const [result] = await this.database.query(
`UPDATE ${this.table} SET super_oauth_id = ? WHERE id = ?`,
[superOAuthId, id]
);
return result.affectedRows;
}
// The Rs of CRUD - Read operations
async read(id, field) {
if (field) {
@@ -69,6 +85,8 @@ class UserManager extends AbstractManager {
"nickname",
"tetardcoin",
"password",
"firstname",
"lastname",
];
const fieldsToUpdate = Object.keys(updatedFields).filter((field) =>