Add complete CKE Project implementation with news management system

This commit is contained in:
albivkt
2025-07-13 01:34:11 +03:00
parent c9317555ca
commit a84810c6b9
32 changed files with 8901 additions and 811 deletions

BIN
prisma/dev.db Normal file

Binary file not shown.

View File

@ -0,0 +1,59 @@
-- CreateTable
CREATE TABLE "news" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"summary" TEXT NOT NULL,
"content" TEXT NOT NULL,
"category" TEXT NOT NULL,
"imageUrl" TEXT,
"featured" BOOLEAN NOT NULL DEFAULT false,
"published" BOOLEAN NOT NULL DEFAULT true,
"publishedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"authorId" TEXT,
"views" INTEGER NOT NULL DEFAULT 0,
"likes" INTEGER NOT NULL DEFAULT 0,
"tags" TEXT NOT NULL DEFAULT '',
CONSTRAINT "news_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "users" (
"id" TEXT NOT NULL PRIMARY KEY,
"email" TEXT NOT NULL,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
"role" TEXT NOT NULL DEFAULT 'USER',
"name" TEXT,
"avatar" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "categories" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"description" TEXT,
"color" TEXT NOT NULL DEFAULT '#3B82F6',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "news_slug_key" ON "news"("slug");
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
-- CreateIndex
CREATE UNIQUE INDEX "categories_name_key" ON "categories"("name");
-- CreateIndex
CREATE UNIQUE INDEX "categories_slug_key" ON "categories"("slug");

View File

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "sqlite"

66
prisma/schema.prisma Normal file
View File

@ -0,0 +1,66 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model News {
id String @id @default(cuid())
title String
slug String @unique
summary String
content String
category String
imageUrl String?
featured Boolean @default(false)
published Boolean @default(true)
publishedAt DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
authorId String?
author User? @relation(fields: [authorId], references: [id])
views Int @default(0)
likes Int @default(0)
tags String @default("")
@@map("news")
}
model User {
id String @id @default(cuid())
email String @unique
username String @unique
password String
role UserRole @default(USER)
name String?
avatar String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
news News[]
@@map("users")
}
model Category {
id String @id @default(cuid())
name String @unique
slug String @unique
description String?
color String @default("#3B82F6")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("categories")
}
enum UserRole {
USER
ADMIN
EDITOR
}