mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-28 22:55:07 +02:00
make all emails lowercase closes #89
This commit is contained in:
parent
d1278c252b
commit
5f92b0bbc1
10 changed files with 73 additions and 15 deletions
40
server/setup/scripts/1.0.0-beta9.ts
Normal file
40
server/setup/scripts/1.0.0-beta9.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import db from "@server/db";
|
||||
import {
|
||||
emailVerificationCodes,
|
||||
passwordResetTokens,
|
||||
resourceOtp,
|
||||
resourceWhitelist,
|
||||
userInvites,
|
||||
users
|
||||
} from "@server/db/schema";
|
||||
import { sql } from "drizzle-orm";
|
||||
|
||||
export default async function migration() {
|
||||
console.log("Running setup script 1.0.0-beta.9...");
|
||||
|
||||
try {
|
||||
await db.transaction(async (trx) => {
|
||||
await db.transaction(async (trx) => {
|
||||
trx.run(sql`UPDATE ${users} SET email = LOWER(email);`);
|
||||
trx.run(
|
||||
sql`UPDATE ${emailVerificationCodes} SET email = LOWER(email);`
|
||||
);
|
||||
trx.run(
|
||||
sql`UPDATE ${passwordResetTokens} SET email = LOWER(email);`
|
||||
);
|
||||
trx.run(sql`UPDATE ${userInvites} SET email = LOWER(email);`);
|
||||
trx.run(
|
||||
sql`UPDATE ${resourceWhitelist} SET email = LOWER(email);`
|
||||
);
|
||||
trx.run(sql`UPDATE ${resourceOtp} SET email = LOWER(email);`);
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"We were unable to make all emails lower case in the database."
|
||||
);
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
console.log("Done.");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue