This commit is contained in:
bipproduction
2025-10-07 16:17:04 +08:00
commit 1c6721a664
63 changed files with 13148 additions and 0 deletions

31
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,31 @@
generator client {
provider = "prisma-client-js"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ApiKey ApiKey[]
}
model ApiKey {
id String @id @default(cuid())
User User? @relation(fields: [userId], references: [id])
userId String
name String
key String @unique @db.Text
description String?
expiredAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

30
prisma/seed.ts Normal file
View File

@@ -0,0 +1,30 @@
import { prisma } from "@/server/lib/prisma";
const user = [
{
name: "Bip",
email: "bip@bip.com",
password: "bip",
}
];
; (async () => {
for (const u of user) {
await prisma.user.upsert({
where: { email: u.email },
create: u,
update: u,
})
console.log(`✅ User ${u.email} seeded successfully`)
}
})().catch((e) => {
console.error(e)
process.exit(1)
}).finally(() => {
console.log("✅ Seeding completed successfully ")
process.exit(0)
})