Loading backend/prisma/migrations/20230608074622_deleted_at/migration.sql 0 → 100644 +47 −0 Original line number Diff line number Diff line -- AlterTable ALTER TABLE "Build" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Category" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "FormFactor" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "IntegratedGraphics" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Manufacturer" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Memory" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "MemoryGeneration" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Motherboard" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "MotherboardChipset" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "MotherboardPcieSlot" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "PcieGeneration" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Preset" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Processor" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Socket" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "VideoCard" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "VideoChipset" ADD COLUMN "deletedAt" DATETIME; backend/prisma/schema.prisma +20 −4 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ model Preset { category Category @relation(fields: [categoryId], references: [id]) buildId String build Build @relation(fields: [buildId], references: [id]) deletedAt DateTime? } model Category { Loading @@ -36,6 +37,7 @@ model Category { name String description String preset Preset[] deletedAt DateTime? } model Build { Loading @@ -49,6 +51,7 @@ model Build { videoCardId String? videoCard VideoCard? @relation(fields: [videoCardId], references: [id]) preset Preset[] deletedAt DateTime? } model Processor { Loading @@ -63,12 +66,14 @@ model Processor { integratedGraphics IntegratedGraphics? @relation(fields: [integratedGraphicsId], references: [id]) integratedGraphicsId String? image String deletedAt DateTime? } model IntegratedGraphics { id String @id @default(uuid()) name String processor Processor[] deletedAt DateTime? } model Socket { Loading @@ -76,6 +81,7 @@ model Socket { name String processor Processor[] motherboard Motherboard[] deletedAt DateTime? } model Motherboard { Loading @@ -94,12 +100,14 @@ model Motherboard { chipsetId String pcieSlots MotherboardPcieSlot[] image String deletedAt DateTime? } model FormFactor { id String @id @default(uuid()) name String motherboards Motherboard[] deletedAt DateTime? } model VideoCard { Loading @@ -115,6 +123,7 @@ model VideoCard { chipsetId String slotSize Int image String deletedAt DateTime? } model Manufacturer { Loading @@ -126,6 +135,7 @@ model Manufacturer { memories Memory[] motherboardChipsets MotherboardChipset[] videoChipsets VideoChipset[] deletedAt DateTime? } model Memory { Loading @@ -138,6 +148,7 @@ model Memory { price Decimal builds Build[] image String deletedAt DateTime? } model MemoryGeneration { Loading @@ -145,6 +156,7 @@ model MemoryGeneration { name String memories Memory[] motherboardChipsets MotherboardChipset[] deletedAt DateTime? } model MotherboardChipset { Loading @@ -155,6 +167,7 @@ model MotherboardChipset { memoryGeneration MemoryGeneration @relation(fields: [memoryGenerationId], references: [id]) memoryGenerationId String motherboards Motherboard[] deletedAt DateTime? } model PcieGeneration { Loading @@ -162,6 +175,7 @@ model PcieGeneration { name String motherboardPcieSlots MotherboardPcieSlot[] videoCards VideoCard[] deletedAt DateTime? } model MotherboardPcieSlot { Loading @@ -172,6 +186,7 @@ model MotherboardPcieSlot { pcieGeneration PcieGeneration @relation(fields: [pcieGenerationId], references: [id]) size Int count Int deletedAt DateTime? } model VideoChipset { Loading @@ -180,4 +195,5 @@ model VideoChipset { manufacturerId String manufacturer Manufacturer @relation(fields: [manufacturerId], references: [id]) videoCards VideoCard[] deletedAt DateTime? } backend/src/repositories/build/create.ts +2 −1 Original line number Diff line number Diff line Loading @@ -3,8 +3,9 @@ import prisma from '../client'; import { withTranslatedErrors } from '../errors'; import { validateBuild } from './common'; import include from './include'; import type { CreateData } from '../common'; export type BuildCreateData = Omit<Build, 'id'>; export type BuildCreateData = CreateData<Build>; export const createBuild = withTranslatedErrors( async (data: BuildCreateData) => { Loading backend/src/repositories/build/delete.ts +2 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ export type BuildDeleteData = Pick<Build, 'id'>; export const deleteBuild = withTranslatedErrors( async (data: BuildDeleteData) => { const result = await prisma.build.delete({ const result = await prisma.build.update({ data: { deletedAt: new Date() }, where: { id: data.id }, }); Loading backend/src/repositories/build/read.ts +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ export const readManyBuild = withTranslatedErrors( // eslint-disable-next-line @typescript-eslint/no-unused-vars async (_data: BuildReadManyData) => { const result = await prisma.build.findMany({ where: { deletedAt: null }, include, }); return result; Loading Loading
backend/prisma/migrations/20230608074622_deleted_at/migration.sql 0 → 100644 +47 −0 Original line number Diff line number Diff line -- AlterTable ALTER TABLE "Build" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Category" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "FormFactor" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "IntegratedGraphics" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Manufacturer" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Memory" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "MemoryGeneration" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Motherboard" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "MotherboardChipset" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "MotherboardPcieSlot" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "PcieGeneration" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Preset" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Processor" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "Socket" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "VideoCard" ADD COLUMN "deletedAt" DATETIME; -- AlterTable ALTER TABLE "VideoChipset" ADD COLUMN "deletedAt" DATETIME;
backend/prisma/schema.prisma +20 −4 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ model Preset { category Category @relation(fields: [categoryId], references: [id]) buildId String build Build @relation(fields: [buildId], references: [id]) deletedAt DateTime? } model Category { Loading @@ -36,6 +37,7 @@ model Category { name String description String preset Preset[] deletedAt DateTime? } model Build { Loading @@ -49,6 +51,7 @@ model Build { videoCardId String? videoCard VideoCard? @relation(fields: [videoCardId], references: [id]) preset Preset[] deletedAt DateTime? } model Processor { Loading @@ -63,12 +66,14 @@ model Processor { integratedGraphics IntegratedGraphics? @relation(fields: [integratedGraphicsId], references: [id]) integratedGraphicsId String? image String deletedAt DateTime? } model IntegratedGraphics { id String @id @default(uuid()) name String processor Processor[] deletedAt DateTime? } model Socket { Loading @@ -76,6 +81,7 @@ model Socket { name String processor Processor[] motherboard Motherboard[] deletedAt DateTime? } model Motherboard { Loading @@ -94,12 +100,14 @@ model Motherboard { chipsetId String pcieSlots MotherboardPcieSlot[] image String deletedAt DateTime? } model FormFactor { id String @id @default(uuid()) name String motherboards Motherboard[] deletedAt DateTime? } model VideoCard { Loading @@ -115,6 +123,7 @@ model VideoCard { chipsetId String slotSize Int image String deletedAt DateTime? } model Manufacturer { Loading @@ -126,6 +135,7 @@ model Manufacturer { memories Memory[] motherboardChipsets MotherboardChipset[] videoChipsets VideoChipset[] deletedAt DateTime? } model Memory { Loading @@ -138,6 +148,7 @@ model Memory { price Decimal builds Build[] image String deletedAt DateTime? } model MemoryGeneration { Loading @@ -145,6 +156,7 @@ model MemoryGeneration { name String memories Memory[] motherboardChipsets MotherboardChipset[] deletedAt DateTime? } model MotherboardChipset { Loading @@ -155,6 +167,7 @@ model MotherboardChipset { memoryGeneration MemoryGeneration @relation(fields: [memoryGenerationId], references: [id]) memoryGenerationId String motherboards Motherboard[] deletedAt DateTime? } model PcieGeneration { Loading @@ -162,6 +175,7 @@ model PcieGeneration { name String motherboardPcieSlots MotherboardPcieSlot[] videoCards VideoCard[] deletedAt DateTime? } model MotherboardPcieSlot { Loading @@ -172,6 +186,7 @@ model MotherboardPcieSlot { pcieGeneration PcieGeneration @relation(fields: [pcieGenerationId], references: [id]) size Int count Int deletedAt DateTime? } model VideoChipset { Loading @@ -180,4 +195,5 @@ model VideoChipset { manufacturerId String manufacturer Manufacturer @relation(fields: [manufacturerId], references: [id]) videoCards VideoCard[] deletedAt DateTime? }
backend/src/repositories/build/create.ts +2 −1 Original line number Diff line number Diff line Loading @@ -3,8 +3,9 @@ import prisma from '../client'; import { withTranslatedErrors } from '../errors'; import { validateBuild } from './common'; import include from './include'; import type { CreateData } from '../common'; export type BuildCreateData = Omit<Build, 'id'>; export type BuildCreateData = CreateData<Build>; export const createBuild = withTranslatedErrors( async (data: BuildCreateData) => { Loading
backend/src/repositories/build/delete.ts +2 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ export type BuildDeleteData = Pick<Build, 'id'>; export const deleteBuild = withTranslatedErrors( async (data: BuildDeleteData) => { const result = await prisma.build.delete({ const result = await prisma.build.update({ data: { deletedAt: new Date() }, where: { id: data.id }, }); Loading
backend/src/repositories/build/read.ts +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ export const readManyBuild = withTranslatedErrors( // eslint-disable-next-line @typescript-eslint/no-unused-vars async (_data: BuildReadManyData) => { const result = await prisma.build.findMany({ where: { deletedAt: null }, include, }); return result; Loading