import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); async function main() { console.log("🌱 Seeding database..."); // Create tags const tagCheap = await prisma.tag.upsert({ where: { slug: "guenstig" }, update: {}, create: { name: "Günstig", slug: "guenstig", color: "#22c55e", }, }); const tagFavorite = await prisma.tag.upsert({ where: { slug: "favorit" }, update: {}, create: { name: "Favorit", slug: "favorit", color: "#eab308", }, }); const tagGroup = await prisma.tag.upsert({ where: { slug: "gruppe" }, update: {}, create: { name: "Für Gruppen", slug: "gruppe", color: "#8b5cf6", }, }); // Create sample listings const listing1 = await prisma.listing.upsert({ where: { slug: "loft-mit-elbblick-12345678" }, update: {}, create: { title: "Loft mit Elbblick", slug: "loft-mit-elbblick-12345678", airbnbUrl: "https://www.airbnb.com/rooms/12345678", normalizedUrl: "https://airbnb.com/rooms/12345678", externalId: "12345678", locationText: "Dresden, Sachsen", latitude: 51.0504, longitude: 13.7373, nightlyPrice: 129.00, rating: 4.91, reviewCount: 87, officialGuestCount: 4, maxSleepingPlaces: 4, suitableFor4: true, extraMattressesNeededFor4: 0, bedTypesSummary: "1× Doppelbett, 1× Schlafsofa", bedrooms: 2, beds: 2, bathrooms: 1.0, description: "Wunderschönes Loft mit Blick auf die Elbe. Perfekt für Paare oder kleine Gruppen.", hostName: "Anna", isFavorite: true, status: "SHORTLIST", coverImage: "https://images.unsplash.com/photo-1502672260266-1c1ef2d93688?w=800", }, }); // Add sleeping options await prisma.listingSleepingOption.createMany({ data: [ { listingId: listing1.id, bedType: "DOUBLE", quantity: 1, spotsPerUnit: 2, quality: "FULL", }, { listingId: listing1.id, bedType: "SOFA_BED", quantity: 1, spotsPerUnit: 2, quality: "FULL", }, ], }); // Add tags await prisma.listingTag.createMany({ data: [ { listingId: listing1.id, tagId: tagFavorite.id }, { listingId: listing1.id, tagId: tagGroup.id }, ], }); // Second listing const listing2 = await prisma.listing.upsert({ where: { slug: "moderne-wohnung-zentrum-87654321" }, update: {}, create: { title: "Moderne Wohnung im Zentrum", slug: "moderne-wohnung-zentrum-87654321", airbnbUrl: "https://www.airbnb.com/rooms/87654321", normalizedUrl: "https://airbnb.com/rooms/87654321", externalId: "87654321", locationText: "Leipzig, Sachsen", latitude: 51.3397, longitude: 12.3731, nightlyPrice: 89.00, rating: 4.78, reviewCount: 42, officialGuestCount: 3, maxSleepingPlaces: 3, suitableFor4: false, extraMattressesNeededFor4: 1, bedTypesSummary: "1× Doppelbett, 1× Einzelbett", bedrooms: 1, beds: 2, bathrooms: 1.0, description: "Zentral gelegene Wohnung mit modernem Komfort.", hostName: "Thomas", isFavorite: false, status: "INTERESTING", coverImage: "https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=800", }, }); await prisma.listingSleepingOption.createMany({ data: [ { listingId: listing2.id, bedType: "DOUBLE", quantity: 1, spotsPerUnit: 2, quality: "FULL", }, { listingId: listing2.id, bedType: "SINGLE", quantity: 1, spotsPerUnit: 1, quality: "FULL", }, ], }); await prisma.listingTag.create({ data: { listingId: listing2.id, tagId: tagCheap.id }, }); // Third listing const listing3 = await prisma.listing.upsert({ where: { slug: "luxus-penthouse-berlin-55555555" }, update: {}, create: { title: "Luxus-Penthouse am Alexanderplatz", slug: "luxus-penthouse-berlin-55555555", airbnbUrl: "https://www.airbnb.com/rooms/55555555", normalizedUrl: "https://airbnb.com/rooms/55555555", externalId: "55555555", locationText: "Berlin, Mitte", latitude: 52.5200, longitude: 13.4050, nightlyPrice: 299.00, rating: 4.95, reviewCount: 156, officialGuestCount: 6, maxSleepingPlaces: 6, suitableFor4: true, extraMattressesNeededFor4: 0, bedTypesSummary: "2× Doppelbett, 1× Schlafsofa", bedrooms: 3, beds: 3, bathrooms: 2.0, description: "Luxuriöses Penthouse mit 360° Aussicht über Berlin. Perfekt für besondere Anlässe.", hostName: "Sophie", isFavorite: true, status: "SHORTLIST", coverImage: "https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=800", }, }); await prisma.listingSleepingOption.createMany({ data: [ { listingId: listing3.id, bedType: "DOUBLE", quantity: 2, spotsPerUnit: 2, quality: "FULL", }, { listingId: listing3.id, bedType: "SOFA_BED", quantity: 1, spotsPerUnit: 2, quality: "FULL", }, ], }); await prisma.listingTag.createMany({ data: [ { listingId: listing3.id, tagId: tagFavorite.id }, { listingId: listing3.id, tagId: tagGroup.id }, ], }); console.log("✅ Database seeded successfully!"); console.log(` - ${3} listings created`); console.log(` - ${3} tags created`); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });