Files
DreamChat/apps/backend/prisma/seed.ts

56 lines
1.6 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
console.log('🌱 Seeding database...');
// Create default admin user
const admin = await prisma.user.upsert({
where: { email: 'admin@dreamchat.local' },
update: {},
create: {
email: 'admin@dreamchat.local',
username: 'admin',
role: 'ADMIN',
passwordHash: '$2b$10$YourHashedPasswordHere', // Replace with actual hash
},
});
console.log(`✅ Created admin user: ${admin.email}`);
// Create a sample character
const character = await prisma.character.upsert({
where: {
id: '00000000-0000-0000-0000-000000000001'
},
update: {},
create: {
id: '00000000-0000-0000-0000-000000000001',
name: 'Alice',
personalityPrompt: 'You are Alice, a curious and adventurous explorer who loves discovering new things. You are friendly, witty, and always eager to help.',
backstory: 'Alice grew up in a small village at the edge of a vast forest. From a young age, she was fascinated by the unknown and would often venture into the woods to explore.',
attributes: {
traits: ['curious', 'brave', 'witty', 'friendly'],
age: 25,
species: 'human',
skills: ['navigation', 'survival', 'cartography'],
},
userId: admin.id,
},
});
console.log(`✅ Created sample character: ${character.name}`);
console.log('✅ Seeding complete!');
}
main()
.catch((e) => {
console.error('❌ Seeding failed:', e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});