first commit
This commit is contained in:
35
make-admin.ts
Normal file
35
make-admin.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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();
|
||||
Reference in New Issue
Block a user