first commit
This commit is contained in:
13
prisma/migrations/20250809040442_init/migration.sql
Normal file
13
prisma/migrations/20250809040442_init/migration.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `Post` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`subject` VARCHAR(191) NOT NULL,
|
||||
`pubDate` DATETIME(3) NOT NULL,
|
||||
`views` INTEGER NOT NULL,
|
||||
`validViews` INTEGER NOT NULL,
|
||||
`premiumViews` INTEGER NOT NULL,
|
||||
`watchTime` INTEGER NOT NULL,
|
||||
`publisher` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
2
prisma/migrations/20250809040616_init/migration.sql
Normal file
2
prisma/migrations/20250809040616_init/migration.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `Post` MODIFY `publisher` VARCHAR(191) NULL;
|
||||
22
prisma/migrations/20250809040702_init/migration.sql
Normal file
22
prisma/migrations/20250809040702_init/migration.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `Post` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE `Post`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `content` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`subject` VARCHAR(191) NOT NULL,
|
||||
`pubDate` DATETIME(3) NOT NULL,
|
||||
`views` INTEGER NOT NULL,
|
||||
`validViews` INTEGER NOT NULL,
|
||||
`premiumViews` INTEGER NOT NULL,
|
||||
`watchTime` INTEGER NOT NULL,
|
||||
`publisher` VARCHAR(191) NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
18
prisma/migrations/20250817093657_mig/migration.sql
Normal file
18
prisma/migrations/20250817093657_mig/migration.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `noticeBoard` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`title` VARCHAR(191) NOT NULL,
|
||||
`content` VARCHAR(191) NOT NULL,
|
||||
`pubDate` DATETIME(3) NOT NULL,
|
||||
`isDeleted` BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `noticeBoardTag` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `tag` to the `noticeBoard` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `content` ADD COLUMN `owner` VARCHAR(191) NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `noticeBoard` ADD COLUMN `tag` VARCHAR(191) NOT NULL,
|
||||
MODIFY `content` LONGTEXT NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `registerChannel` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`email` VARCHAR(191) NOT NULL,
|
||||
`handle` VARCHAR(191) NOT NULL,
|
||||
`randomcode` VARCHAR(191) NOT NULL,
|
||||
`createtime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
11
prisma/migrations/20250822203011_/migration.sql
Normal file
11
prisma/migrations/20250822203011_/migration.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `userHandle` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`email` VARCHAR(191) NOT NULL,
|
||||
`handle` VARCHAR(191) NOT NULL,
|
||||
`isApproved` BOOLEAN NOT NULL DEFAULT false,
|
||||
`createtime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
UNIQUE INDEX `userHandle_handle_key`(`handle`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
10
prisma/migrations/20250823131705_handle/migration.sql
Normal file
10
prisma/migrations/20250823131705_handle/migration.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- DropIndex
|
||||
DROP INDEX `userHandle_handle_key` ON `userHandle`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `GlobalValue` (
|
||||
`id` INTEGER NOT NULL DEFAULT 1,
|
||||
`costPerView` DOUBLE NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
2
prisma/migrations/20250823135944_handle/migration.sql
Normal file
2
prisma/migrations/20250823135944_handle/migration.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `userHandle` ADD COLUMN `icon` VARCHAR(191) NOT NULL DEFAULT '';
|
||||
16
prisma/migrations/20250824044021_/migration.sql
Normal file
16
prisma/migrations/20250824044021_/migration.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `GlobalValue` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE `GlobalValue`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `costPerView` (
|
||||
`id` INTEGER NOT NULL DEFAULT 1,
|
||||
`costPerView` DOUBLE NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `owner` on the `content` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `publisher` on the `content` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[handle]` on the table `userHandle` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `content` DROP COLUMN `owner`,
|
||||
DROP COLUMN `publisher`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `ContentHandle` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`contentId` VARCHAR(191) NOT NULL,
|
||||
`handle` VARCHAR(191) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `ContentHandle_contentId_key`(`contentId`),
|
||||
INDEX `ContentHandle_handle_idx`(`handle`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX `userHandle_handle_key` ON `userHandle`(`handle`);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `ContentHandle` ADD CONSTRAINT `ContentHandle_contentId_fkey` FOREIGN KEY (`contentId`) REFERENCES `content`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `ContentHandle` ADD CONSTRAINT `ContentHandle_handle_fkey` FOREIGN KEY (`handle`) REFERENCES `userHandle`(`handle`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `ViewPerDay` (
|
||||
`date` DATETIME(3) NOT NULL,
|
||||
`contented` VARCHAR(191) NOT NULL,
|
||||
`validViewDay` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`date`, `contented`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
22
prisma/migrations/20250829194837_001/migration.sql
Normal file
22
prisma/migrations/20250829194837_001/migration.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `noticeBoardTag` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE `noticeBoardTag`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `contentDayView` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`contentId` VARCHAR(191) NOT NULL,
|
||||
`date` DATETIME(3) NOT NULL,
|
||||
`views` INTEGER NOT NULL,
|
||||
`validViews` INTEGER NOT NULL,
|
||||
`premiumViews` INTEGER NOT NULL,
|
||||
`watchTime` INTEGER NOT NULL,
|
||||
|
||||
UNIQUE INDEX `contentDayView_contentId_date_key`(`contentId`, `date`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
8
prisma/migrations/20250829195118_002/migration.sql
Normal file
8
prisma/migrations/20250829195118_002/migration.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `ViewPerDay` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE `ViewPerDay`;
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal 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 = "mysql"
|
||||
102
prisma/schema.prisma
Normal file
102
prisma/schema.prisma
Normal file
@@ -0,0 +1,102 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../app/generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model content{
|
||||
id String @id @default(uuid())
|
||||
subject String
|
||||
pubDate DateTime
|
||||
views Int
|
||||
validViews Int
|
||||
premiumViews Int
|
||||
watchTime Int
|
||||
// Back relation: a content may link to at most one handle
|
||||
contentHandle ContentHandle?
|
||||
}
|
||||
|
||||
model contentDayView{
|
||||
id String @id @default(uuid())
|
||||
contentId String
|
||||
date DateTime
|
||||
views Int
|
||||
validViews Int
|
||||
premiumViews Int
|
||||
watchTime Int
|
||||
@@unique([contentId, date])
|
||||
}
|
||||
|
||||
|
||||
model userHandle {
|
||||
id String @id @default(uuid())
|
||||
email String
|
||||
handle String @unique
|
||||
icon String @default("")
|
||||
isApproved Boolean @default(false)
|
||||
createtime DateTime @default(now())
|
||||
// Relation: a handle can be linked to many contents
|
||||
contentLinks ContentHandle[]
|
||||
}
|
||||
|
||||
model noticeBoard{
|
||||
id String @id @default(uuid())
|
||||
title String
|
||||
content String @db.LongText
|
||||
tag String
|
||||
pubDate DateTime
|
||||
isDeleted Boolean @default(false)
|
||||
}
|
||||
|
||||
|
||||
model registerChannel {
|
||||
id String @id @default(uuid())
|
||||
email String
|
||||
handle String
|
||||
randomcode String
|
||||
createtime DateTime @default(now())
|
||||
}
|
||||
|
||||
model costPerView{
|
||||
id Int @id @default(1)
|
||||
costPerView Float
|
||||
}
|
||||
|
||||
|
||||
// Mapping table: Each content can be linked to at most one handle (unique contentId)
|
||||
// A handle can have many contents
|
||||
model ContentHandle {
|
||||
id String @id @default(uuid())
|
||||
contentId String @unique
|
||||
handle String
|
||||
|
||||
// Relations
|
||||
content content @relation(fields: [contentId], references: [id])
|
||||
user userHandle @relation(fields: [handle], references: [handle])
|
||||
|
||||
@@index([handle])
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
npx prisma migrate dev --name <migration_name>
|
||||
새로운 마이그레이션 파일 생성
|
||||
npx prisma generate
|
||||
프리즈마 클라이언트 생성
|
||||
npx prisma db push
|
||||
데이터베이스 동기화
|
||||
npx prisma studio
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user