From 8272237d504cd4220248667f61182524bb29f21d Mon Sep 17 00:00:00 2001 From: Benny Samir Hierl Date: Sat, 29 Jan 2022 18:42:26 +0100 Subject: [PATCH] DB schema changed Signed-off-by: Benny Samir Hierl --- .../migration.sql | 6 +++--- prisma/schema.prisma | 10 +++++----- src/api/routes/wishlist/read.ts | 2 +- src/types.ts | 2 +- src/views/DetailView.vue | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename prisma/migrations/{20220126195045_first_migration => 20220129174151_first_migration}/migration.sql (83%) diff --git a/prisma/migrations/20220126195045_first_migration/migration.sql b/prisma/migrations/20220129174151_first_migration/migration.sql similarity index 83% rename from prisma/migrations/20220126195045_first_migration/migration.sql rename to prisma/migrations/20220129174151_first_migration/migration.sql index 3f67d66..f84bb69 100644 --- a/prisma/migrations/20220126195045_first_migration/migration.sql +++ b/prisma/migrations/20220129174151_first_migration/migration.sql @@ -12,12 +12,12 @@ CREATE TABLE "Item" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "title" TEXT NOT NULL, "url" TEXT, - "image" TEXT, + "imageSrc" TEXT, "description" TEXT NOT NULL, "comment" TEXT, "bought" BOOLEAN NOT NULL DEFAULT false, - "wishlistId" TEXT, - CONSTRAINT "Item_wishlistId_fkey" FOREIGN KEY ("wishlistId") REFERENCES "Wishlist" ("id") ON DELETE SET NULL ON UPDATE CASCADE + "wishlistId" TEXT NOT NULL, + CONSTRAINT "Item_wishlistId_fkey" FOREIGN KEY ("wishlistId") REFERENCES "Wishlist" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -- CreateIndex diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a65f1c8..7616486 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -11,10 +11,10 @@ datasource db { } model Wishlist { - id String @id @default(uuid()) + id String @id @default(uuid()) title String imageSrc String - slugUrlText String @unique + slugUrlText String @unique description String? items Item[] } @@ -23,10 +23,10 @@ model Item { id Int @id @default(autoincrement()) title String url String? - image String? + imageSrc String? description String comment String? bought Boolean @default(false) - wishlist Wishlist? @relation(fields: [wishlistId], references: [id]) - wishlistId String? + wishlist Wishlist @relation(fields: [wishlistId], references: [id]) + wishlistId String } diff --git a/src/api/routes/wishlist/read.ts b/src/api/routes/wishlist/read.ts index a2bfc88..389ad37 100644 --- a/src/api/routes/wishlist/read.ts +++ b/src/api/routes/wishlist/read.ts @@ -51,7 +51,7 @@ export const getBySlugUrl = { id: { type: 'number' }, title: { type: 'string' }, url: { type: 'string' }, - image: { type: 'string' }, + imageSrc: { type: 'string' }, description: { type: 'string' }, comment: { type: 'string' }, bought: { type: 'boolean' }, diff --git a/src/types.ts b/src/types.ts index 9c9e85d..de90a26 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,7 @@ export interface WishlistItem { id: string title: string url: string - image: string + imageSrc: string description: string comment: string bought: boolean diff --git a/src/views/DetailView.vue b/src/views/DetailView.vue index 5384338..bdb2d0a 100644 --- a/src/views/DetailView.vue +++ b/src/views/DetailView.vue @@ -46,7 +46,7 @@ const bought = async (item: WishlistItemType): Promise => { :key="index" :title="item.title" :url="item.url" - :image="item.image" + :image="item.imageSrc" :description="item.description" :comment="item.comment" @bought="bought(item)"