Initial commit
This commit is contained in:
18
packages/db/prisma/schema.prisma
Normal file
18
packages/db/prisma/schema.prisma
Normal file
@@ -0,0 +1,18 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
model Post {
|
||||
id String @id @default(uuid())
|
||||
title String
|
||||
slug String @unique
|
||||
excerpt String?
|
||||
body String
|
||||
status String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
24
packages/db/prisma/seed.ts
Normal file
24
packages/db/prisma/seed.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
.finally(async () => {
|
||||
await db.$disconnect()
|
||||
})
|
||||
Reference in New Issue
Block a user