Files
digicraft-be/scripts/transfer_projects.ts
Fahri Can Seçer 80dcf4d04a
Some checks failed
Deploy Backend / deploy (push) Has been cancelled
main
2026-02-05 01:29:22 +03:00

35 lines
1.1 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function transfer() {
// Get target email from CLI args
const targetEmail = process.argv[2];
if (!targetEmail) {
console.error("❌ Usage: npx tsx scripts/transfer_projects.ts <target_email>");
process.exit(1);
}
console.log(`🚚 STARTING MIGRATION to: ${targetEmail}`);
// 1. Find Target User
const targetUser = await prisma.user.findUnique({ where: { email: targetEmail } });
if (!targetUser) {
console.error(`❌ User ${targetEmail} not found. Please register first!`);
process.exit(1);
}
// 2. Update ALL projects to point to this user
// (Except maybe "God Mode Test" projects? No, give them everything)
const result = await prisma.project.updateMany({
data: { userId: targetUser.id }
});
console.log(`✅ SUCCESS: Transferred ${result.count} projects to ${targetEmail}.`);
console.log(`🎉 They should now appear in the dashboard.`);
await prisma.$disconnect();
}
transfer();