Files
image-apiv3/make-admin.ts
Beyhan Oğur 031582ea2c first commit
2026-04-26 22:11:03 +03:00

36 lines
773 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Admin kullanıcı oluşturma scripti
import { db } from "./db";
import { user } from "./db/schema";
import { eq } from "drizzle-orm";
async function makeAdmin() {
const email = process.argv[2];
if (!email) {
console.error("Kullanım: tsx make-admin.mjs email@example.com");
process.exit(1);
}
try {
const result = await db
.update(user)
.set({ role: "admin" })
.where(eq(user.email, email))
.returning();
if (result.length === 0) {
console.error(`${email} bulunamadı`);
process.exit(1);
}
console.log(`${email} artık admin!`);
console.log(result[0]);
process.exit(0);
} catch (error: any) {
console.error("Hata:", error.message);
process.exit(1);
}
}
makeAdmin();