import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); async function main() { console.log('DATABASE_URL:', process.env.DATABASE_URL); /** * 1. USERS (ohne Passwort – Auth kommt später) */ const users = await Promise.all([ prisma.user.upsert({ where: { email: 'alice@onlypets.dev' }, update: {}, create: { email: 'alice@onlypets.dev', name: 'Alice', }, }), prisma.user.upsert({ where: { email: 'bob@onlypets.dev' }, update: {}, create: { email: 'bob@onlypets.dev', name: 'Bob', }, }), prisma.user.upsert({ where: { email: 'carla@onlypets.dev' }, update: {}, create: { email: 'carla@onlypets.dev', name: 'Carla', }, }), ]); /** * 2. PETS */ const pets = await Promise.all([ prisma.pet.create({ data: { name: 'Milo', type: 'Katze', breed: 'EKH', birthDate: new Date('2020-05-12'), ownerId: users[0].id, visibility: 'public', }, }), prisma.pet.create({ data: { name: 'Luna', type: 'Hund', breed: 'Labrador', birthDate: new Date('2019-11-03'), ownerId: users[1].id, visibility: 'followers', }, }), prisma.pet.create({ data: { name: 'Oscar', type: 'Katze', breed: 'BKH', birthDate: new Date('2022-02-01'), ownerId: users[2].id, visibility: 'public', }, }), ]); /** * 3. POSTS */ await Promise.all([ prisma.post.create({ data: { content: 'Milo liebt die Sonne ☀️', authorId: users[0].id, petId: pets[0].id, }, }), prisma.post.create({ data: { content: 'Luna beim Spaziergang 🐕', authorId: users[1].id, petId: pets[1].id, }, }), prisma.post.create({ data: { content: 'Oscar schläft schon wieder 😴', authorId: users[2].id, petId: pets[2].id, }, }), ]); /** * 4. FOLLOWS */ await Promise.all([ prisma.follow.create({ data: { followerId: users[0].id, followingId: users[1].id, }, }), prisma.follow.create({ data: { followerId: users[0].id, followingId: users[2].id, }, }), prisma.follow.create({ data: { followerId: users[1].id, followingId: users[2].id, }, }), ]); console.log('✅ Seed erfolgreich ausgeführt'); } main() .catch((e) => { console.error('❌ Seed fehlgeschlagen:', e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });