first commit

This commit is contained in:
2026-05-24 11:49:14 +03:30
commit 82e401e2f6
46 changed files with 11606 additions and 0 deletions

31
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,31 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum Role {
SUPERADMIN
ADMIN
EDITOR
}
model User {
id String @id @default(cuid())
name String
email String @unique
passwordHash String
role Role @default(EDITOR)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model SiteContent {
id String @id @default("main")
content Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

37
prisma/seed.ts Normal file
View File

@@ -0,0 +1,37 @@
import { PrismaClient, Role } from "@prisma/client";
import { hashSync } from "bcryptjs";
import { defaultSiteContent } from "../src/lib/default-content";
const prisma = new PrismaClient();
async function main() {
await prisma.siteContent.upsert({
where: { id: "main" },
update: { content: defaultSiteContent as unknown as object },
create: {
id: "main",
content: defaultSiteContent as unknown as object
}
});
await prisma.user.upsert({
where: { email: "superadmin@example.com" },
update: {},
create: {
name: "Super Admin",
email: "superadmin@example.com",
passwordHash: hashSync("ChangeMe123!", 10),
role: Role.SUPERADMIN
}
});
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (error) => {
console.error(error);
await prisma.$disconnect();
process.exit(1);
});