28 lines
719 B
TypeScript
28 lines
719 B
TypeScript
/**
|
|
* Usage: npx ts-node prisma/make-admin.ts <email>
|
|
* Promotes an existing user to app-level admin (isAppAdmin = true) by email.
|
|
* Run this once after the first Google sign-in.
|
|
*/
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const email = process.argv[2];
|
|
if (!email) {
|
|
console.error('Usage: npx ts-node prisma/make-admin.ts <email>');
|
|
process.exit(1);
|
|
}
|
|
|
|
const user = await prisma.user.update({
|
|
where: { email },
|
|
data: { isAppAdmin: true },
|
|
});
|
|
|
|
console.log(`✓ ${user.name} (${user.email}) is now an app admin`);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => { console.error(e); process.exit(1); })
|
|
.finally(() => prisma.$disconnect());
|