Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge route separation to Main #22

Merged
merged 4 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "owr-api",
"version": "0.0.1",
"version": "1.0.0-beta",
"description": "",
"author": "",
"private": true,
Expand Down
94 changes: 47 additions & 47 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions prisma/migrations/20240518080728_delete_cascade/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_webtoon_genres" (
"webtoon_id" INTEGER NOT NULL,
"genre_id" INTEGER NOT NULL,

PRIMARY KEY ("webtoon_id", "genre_id"),
CONSTRAINT "webtoon_genres_webtoon_id_fkey" FOREIGN KEY ("webtoon_id") REFERENCES "webtoons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "webtoon_genres_genre_id_fkey" FOREIGN KEY ("genre_id") REFERENCES "genres" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_webtoon_genres" ("genre_id", "webtoon_id") SELECT "genre_id", "webtoon_id" FROM "webtoon_genres";
DROP TABLE "webtoon_genres";
ALTER TABLE "new_webtoon_genres" RENAME TO "webtoon_genres";
CREATE TABLE "new_episode_images" (
"number" INTEGER NOT NULL,
"episode_id" INTEGER NOT NULL,
"image_id" INTEGER NOT NULL,

PRIMARY KEY ("episode_id", "number"),
CONSTRAINT "episode_images_episode_id_fkey" FOREIGN KEY ("episode_id") REFERENCES "episodes" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "episode_images_image_id_fkey" FOREIGN KEY ("image_id") REFERENCES "images" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_episode_images" ("episode_id", "image_id", "number") SELECT "episode_id", "image_id", "number" FROM "episode_images";
DROP TABLE "episode_images";
ALTER TABLE "new_episode_images" RENAME TO "episode_images";
CREATE TABLE "new_episodes" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"title" TEXT NOT NULL,
"number" INTEGER NOT NULL,
"webtoon_id" INTEGER NOT NULL,
"thumbnail_id" INTEGER NOT NULL,
CONSTRAINT "episodes_webtoon_id_fkey" FOREIGN KEY ("webtoon_id") REFERENCES "webtoons" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "episodes_thumbnail_id_fkey" FOREIGN KEY ("thumbnail_id") REFERENCES "images" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_episodes" ("id", "number", "thumbnail_id", "title", "webtoon_id") SELECT "id", "number", "thumbnail_id", "title", "webtoon_id" FROM "episodes";
DROP TABLE "episodes";
ALTER TABLE "new_episodes" RENAME TO "episodes";
CREATE UNIQUE INDEX "episodes_webtoon_id_number_key" ON "episodes"("webtoon_id", "number");
PRAGMA foreign_key_check("webtoon_genres");
PRAGMA foreign_key_check("episode_images");
PRAGMA foreign_key_check("episodes");
PRAGMA foreign_keys=ON;
6 changes: 3 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ model Genres {
model WebtoonGenres {
webtoon_id Int
genre_id Int
webtoon Webtoons @relation(fields: [webtoon_id], references: [id])
webtoon Webtoons @relation(fields: [webtoon_id], references: [id], onDelete: Cascade)
genre Genres @relation(fields: [genre_id], references: [id])

@@id([webtoon_id, genre_id])
Expand Down Expand Up @@ -79,7 +79,7 @@ model Episodes {
title String
number Int
webtoon_id Int
webtoon Webtoons @relation(fields: [webtoon_id], references: [id])
webtoon Webtoons @relation(fields: [webtoon_id], references: [id], onDelete: Cascade)
thumbnail_id Int
thumbnail Images @relation(fields: [thumbnail_id], references: [id])
episode_images EpisodeImages[]
Expand All @@ -91,7 +91,7 @@ model Episodes {
model EpisodeImages {
number Int
episode_id Int
episode Episodes @relation(fields: [episode_id], references: [id])
episode Episodes @relation(fields: [episode_id], references: [id], onDelete: Cascade)
image_id Int
image Images @relation(fields: [image_id], references: [id])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ import {ApiProperty} from "@nestjs/swagger";
export default class EpisodeResponse{
@ApiProperty()
title: string;
@ApiProperty()
images: string[];

constructor(
title: string,
images: string[]
){
this.title = title;
this.images = images;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ApiProperty} from "@nestjs/swagger";

export default class WebtoonResponse{
export default class LightWebtoonResponse{
@ApiProperty()
id: number;
@ApiProperty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
import EpisodeLineModel from "../models/episode-line.model";
import {ApiProperty} from "@nestjs/swagger";
import LightWebtoonResponse from "./light-webtoon-response";

export default class EpisodesResponse{
@ApiProperty()
episodes: EpisodeLineModel[];
export default class WebtoonResponse extends LightWebtoonResponse{
@ApiProperty()
backgroundBanner: string;
@ApiProperty()
topBanner: string;
@ApiProperty()
mobileBanner: string;
@ApiProperty()
title: string;
@ApiProperty()
author: string;

constructor(
episodes: EpisodeLineModel[],
id: number,
title: string,
language: string,
thumbnail: string,
author: string,
backgroundBanner: string,
topBanner: string,
mobileBanner: string,
title: string,
author: string
){
this.episodes = episodes;
super(id, title, language, thumbnail, author);
this.backgroundBanner = backgroundBanner;
this.topBanner = topBanner;
this.mobileBanner = mobileBanner;
this.title = title;
this.author = author;
}

}
Loading
Loading