import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); const galleryUrls = [ 'uploads/gal1.jpg', 'uploads/gal2.jpg', 'uploads/gal3.jpg', 'uploads/gal4.jpg', 'uploads/gal5.jpg', 'uploads/gal6.jpg', 'uploads/gal7.jpg', 'uploads/gal8.jpg', 'uploads/gal9.jpg', 'uploads/gal10.jpg', ]; async function main() { await prisma.review.deleteMany(); await prisma.reservation.deleteMany(); await prisma.yacht.deleteMany(); await prisma.refreshToken.deleteMany(); await prisma.verificationCode.deleteMany(); await prisma.smsSendLog.deleteMany(); await prisma.verifyBlock.deleteMany(); await prisma.user.deleteMany(); const users = await Promise.all([ prisma.user.create({ data: { firstName: 'Иван', lastName: 'Андреев', phone: '+79009009090', email: 'ivan@yachting.ru', password: 'admin', companyName: 'Северный Флот', inn: BigInt(1234567890), ogrn: BigInt(1122334455667), }, }), prisma.user.create({ data: { firstName: 'Сергей', lastName: 'Большаков', phone: '+79119119191', email: 'sergey@yachting.ru', password: 'admin', companyName: 'Балтийские Просторы', inn: BigInt(9876543210), ogrn: BigInt(9988776655443), }, }), prisma.user.create({ data: { firstName: 'Анна', lastName: 'Петрова', phone: '+79229229292', email: 'anna@yachting.ru', password: 'admin', companyName: 'Ладожские Ветры', inn: BigInt(5555555555), ogrn: BigInt(3333444455556), }, }), prisma.user.create({ data: { firstName: 'Дмитрий', lastName: 'Соколов', phone: '+79339339393', email: 'dmitry@yachting.ru', password: 'admin', companyName: 'Финский Залив', inn: BigInt(1111222233), ogrn: BigInt(7777888899990), }, }), ]); const yachtData = [ { name: 'Азимут 55', length: 16.7, speed: 32, minCost: 85000, mainImageUrl: 'uploads/1st.jpg', hasQuickRent: true, isFeatured: true, year: 2022, comfortCapacity: 8, maxCapacity: 12, width: 4.8, cabinsCount: 3, matherial: 'Стеклопластик', power: 1200, description: 'Роскошная моторная яхта Азимут 55 - это воплощение итальянского стиля и российского качества. Идеально подходит для прогулок по Финскому заливу, корпоративных мероприятий и романтических свиданий. На борту: три комфортабельные каюты, просторный салон с панорамным остеклением, полностью оборудованная кухня и две ванные комнаты. Максимальная скорость 32 узла позволяет быстро добраться до самых живописных мест Карельского перешейка.', userId: users[0].id, }, { name: 'Сансикер Манхэттен 52', length: 15.8, speed: 34, minCost: 92000, mainImageUrl: 'uploads/2nd.jpg', hasQuickRent: false, isFeatured: false, topText: '🔥 Лучшее предложение', year: 2023, comfortCapacity: 6, maxCapacity: 10, width: 4.5, cabinsCount: 3, matherial: 'Стеклопластик', power: 1400, description: 'Британский шик и русская душа в одной яхте! Сансикер Манхэттен 52 - выбор настоящих ценителей морских путешествий.', userId: users[1].id, }, { name: 'Принцесс V55', length: 16.7, speed: 33, minCost: 78000, mainImageUrl: 'uploads/3rd.jpg', hasQuickRent: true, isFeatured: false, topText: '🍷 Идеальна для заката с бокалом вина', year: 2021, comfortCapacity: 8, maxCapacity: 12, width: 4.7, cabinsCount: 4, matherial: 'Стеклопластик', power: 1100, description: 'Принцесс V55 - королева российских вод!', userId: users[0].id, }, { name: 'Ферретти 500', length: 15.2, speed: 31, minCost: 68000, mainImageUrl: 'uploads/4th.jpg', hasQuickRent: true, isFeatured: false, topText: '⏳ Часто бронируется - успей', year: 2020, comfortCapacity: 6, maxCapacity: 8, width: 4.3, cabinsCount: 3, matherial: 'Стеклопластик', power: 900, description: 'Итальянская страсть в русской стихии!', userId: users[1].id, }, { name: 'Си Рей 510 Сандансер', length: 15.5, speed: 35, minCost: 72000, mainImageUrl: 'uploads/5th.jpg', hasQuickRent: false, isFeatured: false, year: 2023, comfortCapacity: 8, maxCapacity: 10, width: 4.6, cabinsCount: 3, matherial: 'Стеклопластик', power: 1300, description: 'Американская мощь для русского моря!', userId: users[0].id, }, { name: 'Бавария SR41', length: 12.5, speed: 28, minCost: 45000, mainImageUrl: 'uploads/6th.jpg', hasQuickRent: true, isFeatured: false, year: 2019, comfortCapacity: 6, maxCapacity: 8, width: 3.9, cabinsCount: 2, matherial: 'Стеклопластик', power: 320, description: 'Немецкое качество для русского характера!', userId: users[1].id, }, { name: 'Жанно Мери Фишер 895', length: 8.9, speed: 25, minCost: 32000, mainImageUrl: 'uploads/1st.jpg', hasQuickRent: true, isFeatured: false, year: 2022, comfortCapacity: 4, maxCapacity: 6, width: 3.0, cabinsCount: 1, matherial: 'Стеклопластик', power: 250, description: 'Французская элегантность для русского простора!', userId: users[0].id, }, { name: 'Бенето Свифт Троулер 41', length: 12.5, speed: 22, minCost: 55000, mainImageUrl: 'uploads/2nd.jpg', hasQuickRent: false, isFeatured: false, year: 2021, comfortCapacity: 6, maxCapacity: 8, width: 4.2, cabinsCount: 2, matherial: 'Стеклопластик', power: 425, description: 'Французский траулер для русского севера!', userId: users[1].id, }, { name: 'Лагун 450', length: 13.5, speed: 20, minCost: 65000, mainImageUrl: 'uploads/3rd.jpg', hasQuickRent: true, isFeatured: false, year: 2020, comfortCapacity: 8, maxCapacity: 10, width: 7.8, cabinsCount: 4, matherial: 'Стеклопластик', power: 90, description: 'Французский катамаран для русского размаха!', userId: users[0].id, }, { name: 'Фонтен Пажо Люсия 40', length: 11.7, speed: 18, minCost: 58000, mainImageUrl: 'uploads/4th.jpg', hasQuickRent: true, isFeatured: false, year: 2023, comfortCapacity: 8, maxCapacity: 10, width: 7.1, cabinsCount: 4, matherial: 'Стеклопластик', power: 80, description: 'Французский катамаран класса люкс!', userId: users[1].id, }, { name: 'Дюфур 460', length: 14.1, speed: 26, minCost: 62000, mainImageUrl: 'uploads/5th.jpg', hasQuickRent: false, isFeatured: false, year: 2022, comfortCapacity: 8, maxCapacity: 10, width: 4.5, cabinsCount: 3, matherial: 'Стеклопластик', power: 380, description: 'Французская парусная яхта для русского ветра!', userId: users[0].id, }, { name: 'Гранд Бэнкс 60', length: 18.3, speed: 24, minCost: 125000, mainImageUrl: 'uploads/6th.jpg', hasQuickRent: true, isFeatured: false, year: 2023, comfortCapacity: 6, maxCapacity: 8, width: 5.2, cabinsCount: 3, matherial: 'Стеклопластик', power: 1600, description: 'Американская легенда для русского океана!', userId: users[1].id, }, ]; const yachts = await Promise.all( yachtData.map((y) => prisma.yacht.create({ data: { ...y, galleryUrls: galleryUrls as object, }, }), ), ); await prisma.reservation.createMany({ data: [ { yachtId: yachts[0].id, reservatorId: users[0].id, startUtc: 1767369600, endUtc: 1767412800 }, { yachtId: yachts[2].id, reservatorId: users[1].id, startUtc: 1767484800, endUtc: 1767715200 }, { yachtId: yachts[4].id, reservatorId: users[0].id, startUtc: 1768070400, endUtc: 1768176000 }, { yachtId: yachts[6].id, reservatorId: users[1].id, startUtc: 1768435200, endUtc: 1768684800 }, { yachtId: yachts[8].id, reservatorId: users[0].id, startUtc: 1768944000, endUtc: 1769049600 }, { yachtId: yachts[10].id, reservatorId: users[1].id, startUtc: 1769385600, endUtc: 1769635200 }, ], }); await prisma.review.createMany({ data: [ { reviewerId: users[0].id, yachtId: yachts[0].id, starsCount: 5, description: 'Excellent yacht!' }, { reviewerId: users[1].id, yachtId: yachts[0].id, starsCount: 4, description: 'Very good experience' }, { reviewerId: users[0].id, yachtId: yachts[2].id, starsCount: 3, description: 'Average condition' }, { reviewerId: users[1].id, yachtId: yachts[4].id, starsCount: 5, description: 'Perfect for sailing' }, { reviewerId: users[0].id, yachtId: yachts[6].id, starsCount: 4, description: 'Comfortable and fast' }, { reviewerId: users[1].id, yachtId: yachts[8].id, starsCount: 2, description: 'Needs maintenance' }, { reviewerId: users[0].id, yachtId: yachts[10].id, starsCount: 5, description: 'Luxury experience' }, { reviewerId: users[1].id, yachtId: yachts[11].id, starsCount: 4, description: 'Great value for money' }, ], }); console.log('Seed completed: users', users.length, 'yachts', yachts.length); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(() => prisma.$disconnect());