diff --git a/src/auth/migrations/AddNameToUsersMigration.ts b/src/auth/migrations/AddNameToUsersMigration.ts index a9eadc6..cf513ab 100644 --- a/src/auth/migrations/AddNameToUsersMigration.ts +++ b/src/auth/migrations/AddNameToUsersMigration.ts @@ -15,10 +15,12 @@ export default class AddNameToUsersMigration extends Migration { // Give every user a random name const users = await User.select().get(this.getCurrentConnection()); + const callbacks: (() => Promise)[] = []; await Promise.all(users.map(user => { user.name = nanoid(); - return user.save(this.getCurrentConnection()); + return user.save(this.getCurrentConnection(), c => callbacks.push(c)); })); + await Promise.all(callbacks); await this.query(`ALTER TABLE users ADD CONSTRAINT UNIQUE (name)`);