219 lines
4.8 KiB
TypeScript
219 lines
4.8 KiB
TypeScript
import { db } from "../src/client"
|
|
|
|
async function main() {
|
|
await db.post.upsert({
|
|
where: { slug: "welcome" },
|
|
update: {},
|
|
create: {
|
|
title: "Welcome to your CMS",
|
|
slug: "welcome",
|
|
excerpt: "Your first seeded post",
|
|
body: "Edit or delete this post from your admin area.",
|
|
status: "published",
|
|
},
|
|
})
|
|
|
|
const media = await db.mediaAsset.upsert({
|
|
where: { storageKey: "seed/artwork-welcome.jpg" },
|
|
update: {},
|
|
create: {
|
|
type: "artwork",
|
|
title: "Seed Artwork Image",
|
|
altText: "Seed artwork placeholder",
|
|
tags: ["seed", "portfolio"],
|
|
storageKey: "seed/artwork-welcome.jpg",
|
|
mimeType: "image/jpeg",
|
|
isPublished: true,
|
|
},
|
|
})
|
|
|
|
const artwork = await db.artwork.upsert({
|
|
where: { slug: "seed-artwork-welcome" },
|
|
update: {},
|
|
create: {
|
|
title: "Seed Artwork",
|
|
slug: "seed-artwork-welcome",
|
|
description: "Baseline seeded artwork for MVP1 media foundation.",
|
|
medium: "Digital",
|
|
year: 2026,
|
|
availability: "available",
|
|
isPublished: true,
|
|
},
|
|
})
|
|
|
|
const gallery = await db.gallery.upsert({
|
|
where: { slug: "featured" },
|
|
update: {},
|
|
create: {
|
|
name: "Featured",
|
|
slug: "featured",
|
|
description: "Featured artwork selection.",
|
|
isVisible: true,
|
|
},
|
|
})
|
|
|
|
await db.artworkGallery.upsert({
|
|
where: {
|
|
artworkId_galleryId: {
|
|
artworkId: artwork.id,
|
|
galleryId: gallery.id,
|
|
},
|
|
},
|
|
create: {
|
|
artworkId: artwork.id,
|
|
galleryId: gallery.id,
|
|
},
|
|
update: {},
|
|
})
|
|
|
|
await db.artworkRendition.upsert({
|
|
where: {
|
|
artworkId_slot: {
|
|
artworkId: artwork.id,
|
|
slot: "thumbnail",
|
|
},
|
|
},
|
|
create: {
|
|
artworkId: artwork.id,
|
|
mediaAssetId: media.id,
|
|
slot: "thumbnail",
|
|
isPrimary: true,
|
|
},
|
|
update: {},
|
|
})
|
|
|
|
await db.systemSetting.upsert({
|
|
where: { key: "public.header_banner" },
|
|
update: {},
|
|
create: {
|
|
key: "public.header_banner",
|
|
value: JSON.stringify({
|
|
enabled: true,
|
|
message: "New portfolio release is live.",
|
|
ctaLabel: "Open latest posts",
|
|
ctaHref: "/",
|
|
}),
|
|
},
|
|
})
|
|
|
|
const homePage = await db.page.upsert({
|
|
where: { slug: "home" },
|
|
update: {},
|
|
create: {
|
|
title: "Home",
|
|
slug: "home",
|
|
status: "published",
|
|
summary: "Default homepage seeded for pages/navigation baseline.",
|
|
content: "Welcome to your new artist CMS homepage.",
|
|
seoTitle: "Home",
|
|
seoDescription: "Seeded homepage",
|
|
publishedAt: new Date(),
|
|
},
|
|
})
|
|
|
|
const primaryMenu = await db.navigationMenu.upsert({
|
|
where: { slug: "primary" },
|
|
update: {},
|
|
create: {
|
|
name: "Primary",
|
|
slug: "primary",
|
|
location: "header",
|
|
isVisible: true,
|
|
},
|
|
})
|
|
|
|
const existingHomeItem = await db.navigationItem.findFirst({
|
|
where: {
|
|
menuId: primaryMenu.id,
|
|
parentId: null,
|
|
sortOrder: 0,
|
|
label: "Home",
|
|
},
|
|
select: {
|
|
id: true,
|
|
},
|
|
})
|
|
|
|
if (existingHomeItem) {
|
|
await db.navigationItem.update({
|
|
where: {
|
|
id: existingHomeItem.id,
|
|
},
|
|
data: {
|
|
pageId: homePage.id,
|
|
href: "/",
|
|
isVisible: true,
|
|
},
|
|
})
|
|
} else {
|
|
await db.navigationItem.create({
|
|
data: {
|
|
menuId: primaryMenu.id,
|
|
label: "Home",
|
|
href: "/",
|
|
pageId: homePage.id,
|
|
parentId: null,
|
|
sortOrder: 0,
|
|
isVisible: true,
|
|
},
|
|
})
|
|
}
|
|
|
|
const existingCustomer = await db.customer.findFirst({
|
|
where: {
|
|
email: "collector@example.com",
|
|
},
|
|
select: {
|
|
id: true,
|
|
},
|
|
})
|
|
|
|
const seededCustomer = existingCustomer
|
|
? await db.customer.update({
|
|
where: {
|
|
id: existingCustomer.id,
|
|
},
|
|
data: {
|
|
name: "Collector One",
|
|
phone: "+1-555-0101",
|
|
isRecurring: true,
|
|
notes: "Interested in recurring portrait commissions.",
|
|
},
|
|
})
|
|
: await db.customer.create({
|
|
data: {
|
|
name: "Collector One",
|
|
email: "collector@example.com",
|
|
phone: "+1-555-0101",
|
|
isRecurring: true,
|
|
notes: "Interested in recurring portrait commissions.",
|
|
},
|
|
})
|
|
|
|
await db.commission.upsert({
|
|
where: {
|
|
id: "11111111-1111-1111-1111-111111111111",
|
|
},
|
|
update: {},
|
|
create: {
|
|
id: "11111111-1111-1111-1111-111111111111",
|
|
title: "Portrait Commission Baseline",
|
|
description: "Initial seeded commission request for MVP1 board validation.",
|
|
status: "new",
|
|
customerId: seededCustomer.id,
|
|
budgetMin: 400,
|
|
budgetMax: 900,
|
|
dueAt: new Date(Date.now() + 14 * 24 * 60 * 60 * 1000),
|
|
},
|
|
})
|
|
}
|
|
|
|
main()
|
|
.catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|
|
.finally(async () => {
|
|
await db.$disconnect()
|
|
})
|