mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
chore: refresh unnamed user (#7544)
This commit is contained in:
@@ -9,9 +9,6 @@ export class UnamedAccount1703756315970 {
|
|||||||
const users = await db.$queryRaw<
|
const users = await db.$queryRaw<
|
||||||
User[]
|
User[]
|
||||||
>`SELECT * FROM users WHERE name ~ E'^[\\s\\u2000-\\u200F]*$';`;
|
>`SELECT * FROM users WHERE name ~ E'^[\\s\\u2000-\\u200F]*$';`;
|
||||||
console.log(
|
|
||||||
`renaming ${users.map(({ email }) => email).join('|')} users`
|
|
||||||
);
|
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
users.map(({ id, email }) =>
|
users.map(({ id, email }) =>
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { PrismaClient, User } from '@prisma/client';
|
||||||
|
|
||||||
|
export class RefreshUnnamedUser1721299086340 {
|
||||||
|
// do the migration
|
||||||
|
static async up(db: PrismaClient) {
|
||||||
|
await db.$transaction(async tx => {
|
||||||
|
// only find users with unnamed names
|
||||||
|
const users = await db.$queryRaw<
|
||||||
|
User[]
|
||||||
|
>`SELECT * FROM users WHERE name = 'Unnamed';`;
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
users.map(({ id, email }) =>
|
||||||
|
tx.user.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
name: email.split('@')[0],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// revert the migration
|
||||||
|
static async down(_db: PrismaClient) {}
|
||||||
|
}
|
||||||
@@ -149,7 +149,6 @@ export async function changePassword(
|
|||||||
variables: { token, password },
|
variables: { token, password },
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
console.log(JSON.stringify(res.body));
|
|
||||||
return res.body.data.changePassword.id;
|
return res.body.data.changePassword.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user