🪻 distributed transcription service thistle.dunkirk.sh
at main 722 B view raw
1#!/usr/bin/env bun 2 3import db from "../src/db/schema"; 4 5const email = process.argv[2]; 6 7if (!email) { 8 console.error("Usage: bun scripts/make-admin.ts <email>"); 9 process.exit(1); 10} 11 12const user = db 13 .query<{ id: number; email: string; role: string }, [string]>( 14 "SELECT id, email, role FROM users WHERE email = ?", 15 ) 16 .get(email); 17 18if (!user) { 19 console.error(`User with email ${email} not found`); 20 process.exit(1); 21} 22 23if (user.role === "admin") { 24 console.log(`User ${email} is already an admin`); 25 process.exit(0); 26} 27 28db.run("UPDATE users SET role = 'admin' WHERE id = ?", [user.id]); 29 30console.log(`✅ Successfully made ${email} an admin`); 31console.log(` User should refresh their browser to see admin access`);