forked from noxious/server
132 lines
3.4 KiB
Plaintext
132 lines
3.4 KiB
Plaintext
// CHEAT SHEET
|
|
// 1. Create a new Prisma project
|
|
// npx prisma init
|
|
// 2. Create a new database schema
|
|
// npx prisma db push
|
|
// 3. Generate Prisma Client
|
|
// npx prisma generate
|
|
// 4. Create a new migration
|
|
// npx prisma migrate dev --name init
|
|
// 5. Apply the migration
|
|
// npx prisma migrate deploy
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Object {
|
|
id String @id @default(uuid())
|
|
name String
|
|
origin_x Decimal @default(0)
|
|
origin_y Decimal @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
ZoneObject ZoneObject[]
|
|
}
|
|
|
|
model Item {
|
|
id String @id @default(uuid())
|
|
name String
|
|
description String
|
|
stackable Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
characters CharacterItem[]
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
password String
|
|
characters Character[]
|
|
}
|
|
|
|
model Character {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
name String @unique
|
|
hitpoints Int @default(100)
|
|
mana Int @default(100)
|
|
level Int @default(1)
|
|
experience Int @default(0)
|
|
role String @default("player")
|
|
position_x Int
|
|
position_y Int
|
|
rotation Int
|
|
zoneId Int
|
|
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
|
chats Chat[]
|
|
items CharacterItem[]
|
|
}
|
|
|
|
model CharacterItem {
|
|
id Int @id @default(autoincrement())
|
|
characterId Int
|
|
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
|
itemId String
|
|
item Item @relation(fields: [itemId], references: [id], onDelete: Cascade)
|
|
quantity Int
|
|
}
|
|
|
|
model TileTag {
|
|
tile String @id
|
|
tags Json
|
|
}
|
|
|
|
model Zone {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
width Int
|
|
height Int
|
|
tiles Json
|
|
zoneEventTiles ZoneEventTile[]
|
|
zoneObjects ZoneObject[]
|
|
characters Character[]
|
|
chats Chat[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model ZoneObject {
|
|
id String @id @default(uuid())
|
|
zoneId Int
|
|
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
|
objectId String
|
|
object Object @relation(fields: [objectId], references: [id])
|
|
depth Int
|
|
position_x Int
|
|
position_y Int
|
|
}
|
|
|
|
enum ZoneEventTileType {
|
|
BLOCK
|
|
WARP
|
|
NPC
|
|
ITEM
|
|
}
|
|
|
|
model ZoneEventTile {
|
|
id String @id @default(uuid())
|
|
zoneId Int
|
|
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
|
type ZoneEventTileType
|
|
position_x Int
|
|
position_y Int
|
|
}
|
|
|
|
model Chat {
|
|
id Int @id @default(autoincrement())
|
|
characterId Int
|
|
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
|
zoneId Int
|
|
zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
|
|
message String
|
|
createdAt DateTime
|
|
}
|