Files
Lucky_Wheel/apps/api/prisma/seed-user.ts
T
2026-09-10 01:58:29 +03:30

53 lines
1.0 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const user = await prisma.user.upsert({
where: { mobile: '09382507041' },
create: {
mobile: '09382507041',
name: 'کاربر ویژه',
status: 'ACTIVE',
},
update: {
status: 'ACTIVE',
},
});
const campaign = await prisma.campaign.findUnique({
where: { slug: 'default-campaign' },
});
if (campaign) {
await prisma.userCampaign.upsert({
where: {
userId_campaignId: {
userId: user.id,
campaignId: campaign.id,
},
},
create: {
userId: user.id,
campaignId: campaign.id,
totalChances: 10,
usedChances: 0,
},
update: {
totalChances: { increment: 10 },
},
});
}
console.log('SUCCESS: User 09382507041 is authorized and ready with 10 chances!');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});