base commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Product" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"title" TEXT NOT NULL,
|
||||
"slug" TEXT NOT NULL,
|
||||
"shortDescription" TEXT,
|
||||
"description" TEXT,
|
||||
"quantity" INTEGER,
|
||||
"materials" TEXT NOT NULL DEFAULT '[]',
|
||||
"priceCents" INTEGER NOT NULL,
|
||||
"imageUrl" TEXT,
|
||||
"published" BOOLEAN NOT NULL DEFAULT false,
|
||||
"inStock" BOOLEAN NOT NULL DEFAULT true,
|
||||
"leadTimeDays" INTEGER,
|
||||
"categoryId" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "Product_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_Product" ("categoryId", "createdAt", "description", "id", "imageUrl", "inStock", "leadTimeDays", "priceCents", "published", "shortDescription", "slug", "title", "updatedAt") SELECT "categoryId", "createdAt", "description", "id", "imageUrl", "inStock", "leadTimeDays", "priceCents", "published", "shortDescription", "slug", "title", "updatedAt" FROM "Product";
|
||||
DROP TABLE "Product";
|
||||
ALTER TABLE "new_Product" RENAME TO "Product";
|
||||
CREATE UNIQUE INDEX "Product_slug_key" ON "Product"("slug");
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
@@ -22,6 +22,10 @@ model Product {
|
||||
slug String @unique
|
||||
shortDescription String?
|
||||
description String?
|
||||
/// Количество на складе (если null — не ведём учёт)
|
||||
quantity Int?
|
||||
/// Материалы (список, например: ["хлопок","дерево"])
|
||||
materials String @default("[]")
|
||||
/// Цена в копейках (целое число, без дробной части)
|
||||
priceCents Int
|
||||
imageUrl String?
|
||||
|
||||
@@ -20,7 +20,10 @@ async function main() {
|
||||
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',
|
||||
@@ -35,7 +38,10 @@ async function main() {
|
||||
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',
|
||||
@@ -44,6 +50,152 @@ async function main() {
|
||||
},
|
||||
})
|
||||
|
||||
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 })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user