import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() async function main() { const toys = await prisma.category.upsert({ where: { slug: 'igrushki' }, update: {}, create: { name: 'Игрушки', slug: 'igrushki', sort: 1 }, }) const gifts = await prisma.category.upsert({ where: { slug: 'suveniry' }, update: {}, create: { name: 'Сувениры', slug: 'suveniry', sort: 2 }, }) await prisma.product.upsert({ where: { slug: 'myagkaya-sova' }, update: {}, create: { title: 'Мягкая сова', slug: 'myagkaya-sova', shortDescription: 'Мягкая игрушка ручной работы.', description: 'Ручная работа, хлопок и синтепон.', materials: JSON.stringify(['хлопок', 'синтепон']), quantity: 3, priceCents: 189000, imageUrl: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=600&q=80', published: true, categoryId: toys.id, }, }) await prisma.product.upsert({ where: { slug: 'suvenir-kolokolchik' }, update: {}, create: { title: 'Колокольчик керамический', slug: 'suvenir-kolokolchik', shortDescription: 'Керамика с ручной росписью.', description: 'Глазурь, ручная роспись.', materials: JSON.stringify(['керамика', 'глазурь']), quantity: 5, priceCents: 45000, imageUrl: 'https://images.unsplash.com/photo-1513519245088-0e12902e5a38?w=600&q=80', published: true, categoryId: gifts.id, }, }) const more = [ { title: 'Зайчик в свитере', slug: 'zaychik-v-svitere', shortDescription: 'Тёплый подарок — мягкий зайчик.', description: 'Мягкая игрушка. Свитер связан вручную.', materials: ['акрил', 'хлопок', 'синтепон'], quantity: 2, priceCents: 219000, imageUrl: 'https://images.unsplash.com/photo-1543852786-1cf6624b9987?w=600&q=80', published: true, categoryId: toys.id, }, { title: 'Подвеска “Лес”', slug: 'podveska-les', shortDescription: 'Лёгкая подвеска из дерева и смолы.', description: 'Фактура дерева + прозрачная смола.', materials: ['дерево', 'эпоксидная смола'], quantity: 8, priceCents: 69000, imageUrl: 'https://images.unsplash.com/photo-1522312346375-d1a52e2b99b3?w=600&q=80', published: true, categoryId: gifts.id, }, { title: 'Набор открыток (3 шт.)', slug: 'nabor-otkrytok-3', shortDescription: 'Мини-коллекция с акварелью.', description: 'Три открытки с авторской акварелью.', materials: ['бумага', 'акварель'], quantity: 12, priceCents: 39000, imageUrl: 'https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?w=600&q=80', published: true, categoryId: gifts.id, }, { title: 'Свеча “Ягоды”', slug: 'svecha-yagody', shortDescription: 'Ароматная свеча с ягодной нотой.', description: 'Соевый воск, хлопковый фитиль.', materials: ['соевый воск', 'ароматизатор', 'хлопковый фитиль'], quantity: 10, priceCents: 55000, imageUrl: 'https://images.unsplash.com/photo-1542315192-1f61a2b1a3c0?w=600&q=80', published: true, categoryId: gifts.id, }, { title: 'Мишка “Карамель”', slug: 'mishka-karamel', shortDescription: 'Плюшевый мишка с вышивкой.', description: 'Плюш, вышивка вручную.', materials: ['плюш', 'нитки'], quantity: 4, priceCents: 199000, imageUrl: 'https://images.unsplash.com/photo-1545315003-c5ad6226c272?w=600&q=80', published: true, categoryId: toys.id, }, { title: 'Брелок макраме', slug: 'brelok-makrame', shortDescription: 'Мини-брелок, плетение макраме.', description: 'Подходит на ключи или рюкзак.', materials: ['хлопковый шнур', 'кольцо'], quantity: 15, priceCents: 25000, imageUrl: 'https://images.unsplash.com/photo-1520975958225-2f3ab6f4c1c1?w=600&q=80', published: true, categoryId: gifts.id, }, { title: 'Кукла “Тильда”', slug: 'kukla-tilda', shortDescription: 'Классическая кукла в стиле тильда.', description: 'Платье шьётся вручную, можно выбрать цвет.', materials: ['хлопок', 'лен', 'синтепух'], quantity: 1, priceCents: 349000, imageUrl: 'https://images.unsplash.com/photo-1563906267088-b029e7101114?w=600&q=80', published: true, categoryId: toys.id, }, { title: 'Ёлочная игрушка “Звезда”', slug: 'elochnaya-igrushka-zvezda', shortDescription: 'Фетр, вышивка, ленточка.', description: 'Лёгкая игрушка для ёлки или декора.', materials: ['фетр', 'нитки'], quantity: 20, priceCents: 29000, imageUrl: 'https://images.unsplash.com/photo-1543589077-47d81606c1bf?w=600&q=80', published: true, categoryId: gifts.id, }, { title: 'Панно “Горы”', slug: 'panno-gory', shortDescription: 'Минималистичное панно на стену.', description: 'Деревянная основа, роспись акрилом.', materials: ['дерево', 'акрил'], quantity: 2, priceCents: 129000, imageUrl: 'https://images.unsplash.com/photo-1452860606245-08befc0ff44b?w=600&q=80', published: true, categoryId: gifts.id, }, { title: 'Мягкий котик (под заказ)', slug: 'myagkiy-kotik-pod-zakaz', shortDescription: 'Можно выбрать цвет и имя.', description: 'Делаем под заказ: выберите цвет и вышивку имени.', materials: ['хлопок', 'синтепон'], quantity: 0, inStock: false, leadTimeDays: 7, priceCents: 229000, imageUrl: 'https://images.unsplash.com/photo-1518791841217-8f162f1e1131?w=600&q=80', published: true, categoryId: toys.id, }, ] for (const p of more) { await prisma.product.upsert({ where: { slug: p.slug }, update: {}, create: { title: p.title, slug: p.slug, shortDescription: p.shortDescription, description: p.description, materials: JSON.stringify(p.materials), quantity: p.quantity, priceCents: p.priceCents, imageUrl: p.imageUrl, published: p.published, inStock: p.inStock ?? true, leadTimeDays: p.leadTimeDays ?? null, categoryId: p.categoryId, }, }) } console.log('Seed готов:', { toys: toys.slug, gifts: gifts.slug }) } main() .catch((e) => { console.error(e) process.exit(1) }) .finally(async () => { await prisma.$disconnect() })