Updated DB models
This commit is contained in:
parent
3f4e9fa36e
commit
ec4a9904f4
@ -20,10 +20,9 @@ CREATE TABLE `Sprite` (
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `SpriteImage` (
|
||||
CREATE TABLE `SpriteAction` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`spriteId` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`action` VARCHAR(191) NOT NULL,
|
||||
`origin_x` DECIMAL(65, 30) NOT NULL DEFAULT 0,
|
||||
`origin_y` DECIMAL(65, 30) NOT NULL DEFAULT 0,
|
||||
@ -173,7 +172,7 @@ ALTER TABLE `Chat` ADD CONSTRAINT `Chat_characterId_fkey` FOREIGN KEY (`characte
|
||||
ALTER TABLE `Chat` ADD CONSTRAINT `Chat_zoneId_fkey` FOREIGN KEY (`zoneId`) REFERENCES `Zone`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `SpriteImage` ADD CONSTRAINT `SpriteImage_spriteId_fkey` FOREIGN KEY (`spriteId`) REFERENCES `Sprite`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `SpriteAction` ADD CONSTRAINT `SpriteAction_spriteId_fkey` FOREIGN KEY (`spriteId`) REFERENCES `Sprite`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `CharacterType` ADD CONSTRAINT `CharacterType_spriteId_fkey` FOREIGN KEY (`spriteId`) REFERENCES `Sprite`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
@ -1,17 +1,16 @@
|
||||
model Sprite {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
spriteImages SpriteImage[]
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
spriteActions SpriteAction[]
|
||||
characterTypes CharacterType[]
|
||||
}
|
||||
|
||||
model SpriteImage {
|
||||
model SpriteAction {
|
||||
id String @id @default(uuid())
|
||||
spriteId String
|
||||
sprite Sprite @relation(fields: [spriteId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
action String
|
||||
origin_x Decimal @default(0)
|
||||
origin_y Decimal @default(0)
|
||||
|
@ -1,18 +1,18 @@
|
||||
import { Server } from 'socket.io'
|
||||
import { TSocket } from '../../../utilities/Types'
|
||||
import prisma from '../../../utilities/Prisma'
|
||||
import type { SpriteImage } from '@prisma/client'
|
||||
import type { SpriteAction } from '@prisma/client'
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
|
||||
type uploadSpriteImage = SpriteImage & {
|
||||
type uploadSpriteAction = SpriteAction & {
|
||||
base64?: string
|
||||
}
|
||||
|
||||
type Payload = {
|
||||
id: string
|
||||
name: string
|
||||
spriteImages: uploadSpriteImage[]
|
||||
spriteActions: uploadSpriteAction[]
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,11 +33,11 @@ export default function (socket: TSocket, io: Server) {
|
||||
},
|
||||
data: {
|
||||
name: data.name,
|
||||
spriteImages: {
|
||||
spriteActions: {
|
||||
deleteMany: {
|
||||
spriteId: data.id
|
||||
},
|
||||
create: data.spriteImages
|
||||
create: data.spriteActions
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ class SpriteRepository {
|
||||
return prisma.sprite.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
spriteImages: true
|
||||
spriteActions: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user