chore(db): remove Prisma facade and drop prisma:generate from CI
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
ca72966a37
commit
422567272c
17 files changed
+182
-1430
No files matched your search
@@ -16,7 +16,8 @@ import {
|
||||
randomBytes,
|
||||
timingSafeEqual,
|
||||
} from "node:crypto";
|
||||
import { prisma } from "../src/lib/prisma";
|
||||
import { eq, isNotNull } from "drizzle-orm";
|
||||
import { db, User } from "../src/lib/db";
|
||||
|
||||
function getKey(appKey: string): Buffer {
|
||||
const raw = appKey.startsWith("base64:")
|
||||
@@ -84,10 +85,10 @@ async function main() {
|
||||
}
|
||||
const key = getKey(appKey);
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: { twoFactorSecret: { not: null } },
|
||||
select: { id: true, twoFactorSecret: true },
|
||||
});
|
||||
const users = await db
|
||||
.select({ id: User.id, twoFactorSecret: User.twoFactorSecret })
|
||||
.from(User)
|
||||
.where(isNotNull(User.twoFactorSecret));
|
||||
|
||||
console.log(`Found ${users.length} user(s) with a twoFactorSecret.`);
|
||||
|
||||
@@ -107,10 +108,10 @@ async function main() {
|
||||
try {
|
||||
const plaintext = decryptCbc(user.twoFactorSecret, key);
|
||||
const reEncrypted = encryptGcm(plaintext, key);
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { twoFactorSecret: reEncrypted },
|
||||
});
|
||||
await db
|
||||
.update(User)
|
||||
.set({ twoFactorSecret: reEncrypted })
|
||||
.where(eq(User.id, user.id));
|
||||
console.log(` [OK] User ${user.id} — migrated`);
|
||||
migrated++;
|
||||
} catch (err) {
|
||||
@@ -125,12 +126,10 @@ async function main() {
|
||||
if (errors > 0) process.exit(1);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
/* ---- helpers (mirrored from laravel-encrypter.ts) ---- */
|
||||
|
||||
|
||||
Reference in new issue
Block a user