[db] fix migration async execution issue
This commit is contained in:
parent
8bbddf94ff
commit
7735e67f50
|
@ -7,17 +7,3 @@ async function migrate() {
|
|||
}
|
||||
|
||||
migrate();
|
||||
|
||||
// temporary code for a non-sqlite migration:
|
||||
const normalise = s => s.trim().toLowerCase();
|
||||
|
||||
async function populateUsernameNorm() {
|
||||
const db = await dbConnection();
|
||||
for ({id, username} of await db.all(`SELECT id, username FROM users WHERE usernameNorm IS NULL`)) {
|
||||
const norm = normalise(username); // username is safe, so so will be norm
|
||||
console.log(username, norm)
|
||||
await db.all(`UPDATE users SET usernameNorm = '${norm}' WHERE id = '${id}'`);
|
||||
}
|
||||
await db.close();
|
||||
}
|
||||
populateUsernameNorm();
|
||||
|
|
Reference in New Issue