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