mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 22:49:27 +02:00
make all emails lowercase closes #89
This commit is contained in:
parent
f378d77f8f
commit
ece694ff20
10 changed files with 73 additions and 15 deletions
|
@ -11,7 +11,7 @@ import m2 from "./scripts/1.0.0-beta2";
|
|||
import m3 from "./scripts/1.0.0-beta3";
|
||||
import m4 from "./scripts/1.0.0-beta5";
|
||||
import m5 from "./scripts/1.0.0-beta6";
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import m6 from "./scripts/1.0.0-beta9";
|
||||
|
||||
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
||||
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
||||
|
@ -22,7 +22,8 @@ const migrations = [
|
|||
{ version: "1.0.0-beta.2", run: m2 },
|
||||
{ version: "1.0.0-beta.3", run: m3 },
|
||||
{ version: "1.0.0-beta.5", run: m4 },
|
||||
{ version: "1.0.0-beta.6", run: m5 }
|
||||
{ version: "1.0.0-beta.6", run: m5 },
|
||||
{ version: "1.0.0-beta.9", run: m6 }
|
||||
// Add new migrations here as they are created
|
||||
] as const;
|
||||
|
||||
|
|
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