55 lines
1.4 KiB
TypeScript
55 lines
1.4 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.',
|
|
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();
|
|
});
|