import { PrismaClient } from '@prisma/client' import ShortUniqueId from 'short-unique-id' import { checkIfProdEnvironment, formatCurrency, getRandomBool, getRandomDateLastSixMonths, getRandomDecimalNumber, getRandomEnumValueByEnumType, getRandomFirstName, getRandomNumericValueByRange, getRandomPhoneNumber, getRandomSurname, } from './utilities' const prisma = new PrismaClient() const { argv } = require('yargs/yargs')(process.argv.slice(2)) const { randomUUID } = new ShortUniqueId({ length: 10 }) export const seedTestDatabase = async () => { const seedEverything = argv.everything ?? false checkIfProdEnvironment() try { // Add respective model seeding functions here await seedSomething(seedEverything) console.log('✅ Seed script successful!') await prisma.$disconnect() } catch (error: any) { console.error('Error with seed script!', error) await prisma.$disconnect() } } /// //////////////////////////// /// // SEED DATA FUNCTIONS ///// /// //////////////////////////// const seedSomething = async (seedEverything: boolean) => { // await prisma.???.createMany({ // data: [ // { // id: 'User1', // email: 'user1@domain.com', // first: 'User', // surname: 'One', // }, { // id: 'User2', // email: 'user2@domain.com', // first: 'User', // surname: 'Two', // } // ] // }) if (seedEverything) { const data = Array.from({ length: 50 }, (_, index) => ({ id: `user-id-${index + 1}`, email: `user${index + 1}@domain.com`, phone: getRandomPhoneNumber(), username: `User ${index + 1}`, first: `${getRandomFirstName()}_${index + 1}`, surname: `${getRandomSurname()}_${index + 1}`, isOnboarded: true, })) // await prisma.???.createMany({ data }); } } seedTestDatabase()