Skip to content

Commit

Permalink
feat: added prisma to monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 committed Aug 22, 2024
1 parent 3799aa8 commit a64381d
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ PRIVATE_WEBSITE_BEARER=""
# WebSocket server with event messages
PUBLIC_WEBSOCKET_URL=""

# Database
DATABASE_URL=""

# App version
VERSION=""
370 changes: 370 additions & 0 deletions libs/prisma-schema/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,370 @@
generator client {
provider = "prisma-client-js"
// output into a separate subdirectory so multiple schemas can be used in a monorepo
// this make the import path `@prisma/client/one` instead of `@prisma/client`
// Customize to make the most sense for your project
// output = "../../../node_modules/@prisma/client/one"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Profile {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
twitchId String @map("twitch_id")
userName String @map("user_name")
isStreamer Boolean @default(false)
coupons Int @default(0)
coins Int @default(0)
mana Int @default(0)
level Int @default(1)
points Int @default(0)
patronPoints Int @default(0) @map("patron_points")
trophyHunterPoints Int @default(0) @map("trophy_hunter_points")
rangerPoints Int @default(0) @map("ranger_points")
storytellerPoints Int @default(0) @map("storyteller_points")
collectorPoints Int @default(0) @map("collector_points")
activeEditionId String @map("active_edition_id")
posts Post[]
quests Quest[]
questEditions QuestEdition[]
twitchTokens TwitchToken[]
characters Character[]
characterEditions CharacterEdition[]
transactions Transaction[]
trophies Trophy[]
trophyEditions TrophyEdition[]
@@map("profile")
}

model Payment {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
externalId String @map("external_id")
provider String
status String
amount Int @default(0)
profileId String @map("profile_id")
productId String @map("product_id")
@@map("payment")
}

model Product {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
title String
price Int @default(0)
@@map("product")
}

model TwitchToken {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
onlineAt DateTime @default(now()) @map("online_at")
status String
type String
points Int @default(0)
language String @default("ru")
accessTokenId String? @map("access_token_id")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
@@map("twitch_token")
}

model TwitchAccessToken {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
userId String @map("user_id")
accessToken String @map("access_token")
refreshToken String? @map("refresh_token")
scope String[] @map("scope")
expiresIn Int? @map("expires_in")
obtainmentTimestamp String @map("obtainment_timestamp")
@@map("twitch_access_token")
}

model Village {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
globalTarget Int? @map("global_target")
globalTargetSuccess Int? @map("global_target_success")
wood Int @default(0) @map("wood")
stone Int @default(0) @map("stone")
@@map("village")
}

model Player {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
lastActionAt DateTime @default(now()) @map("last_action_at")
name String @map("name")
coins Int @default(0)
reputation Int @default(0)
viewerPoints Int @default(0) @map("viewer_points")
villainPoints Int @default(0) @map("villain_points")
refuellerPoints Int @default(0) @map("refueller_points")
raiderPoints Int @default(0) @map("raider_points")
inventoryId String @map("inventory_id")
profileId String @map("profile_id")
@@map("player")
}

model Skill {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
type String
lvl Int @default(0)
xp Int @default(0)
xpNextLvl Int @default(20) @map("xp_next_lvl")
objectId String @map("object_id")
@@map("skill")
}

model Inventory {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
objectId String @map("object_id")
items InventoryItem[]
@@map("inventory")
}

model InventoryItem {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
inventoryId String @map("inventory_id")
inventory Inventory @relation(fields: [inventoryId], references: [id])
type String
amount Int @default(1)
durability Int @default(100)
@@map("inventory_item")
}

model ChatCommand {
id String @id
action String
command String
@@map("chat_command")
}

model Character {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
codename String?
nickname String
name String
description String
isReady Boolean @default(false) @map("is_ready")
unlockedBy String @default("COINS") @map("unlocked_by")
price Int @default(0)
animationIdle String? @map("animation_idle")
animationMoving String? @map("animation_moving")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
gameId String @map("game_id")
game Game @relation(fields: [gameId], references: [id])
editions CharacterEdition[]
@@map("character")
}

model CharacterEdition {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
level Int @default(1)
xp Int @default(0)
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
characterId String @map("character_id")
character Character @relation(fields: [characterId], references: [id])
@@map("character_edition")
}

model Post {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
characterId String @map("character_id")
type String
text String
rating Int @default(0)
likes Like[]
@@map("post")
}

model Like {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
profileId String @map("profile_id")
postId String @map("post_id")
post Post @relation(fields: [postId], references: [id])
@@map("like")
}

model Coupon {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
activationCommand String @map("activation_command")
status String
profileId String? @map("profile_id")
@@map("coupon")
}

model Trophy {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
name String
description String
points Int
rarity Int @default(0)
isReady Boolean @default(false) @map("is_ready")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
editions TrophyEdition[]
@@map("trophy")
}

model TrophyEdition {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
trophyId String @map("trophy_id")
trophy Trophy @relation(fields: [trophyId], references: [id])
@@map("trophy_edition")
}

model Quest {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
name String
description String
points Int
progressCompleted Int @default(1) @map("progress_completed")
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
editions QuestEdition[]
rewards QuestReward[]
@@map("quest")
}

model QuestEdition {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
completedAt DateTime? @map("completed_at")
status String
progress Int @default(0)
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
questId String @map("quest_id")
quest Quest @relation(fields: [questId], references: [id])
@@map("quest_edition")
}

model QuestReward {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
type String
amount Int @default(0)
entityId String? @map("entity_id")
questId String @map("quest_id")
quest Quest @relation(fields: [questId], references: [id])
@@map("quest_reward")
}

model Game {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
slug String @unique
title String
imageId String @map("image_id")
charactersCount Int @default(0) @map("characters_count")
characters Character[]
@@map("game")
}

model Transaction {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
amount Int @default(0)
type String
entityId String @map("entity_id")
text String?
profileId String @map("profile_id")
profile Profile @relation(fields: [profileId], references: [id])
@@map("transaction")
}

model Woodland {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
finishedAt DateTime? @map("finished_at")
status String
profileId String @map("profile_id")
tokenId String @map("token_id")
players WoodlandPlayer[]
@@map("woodland")
}

model WoodlandPlayer {
id String @id
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
lastActionAt DateTime @default(now()) @map("last_action_at")
name String
wood Int @default(0)
profileId String @map("profile_id")
woodlandId String @map("woodland_id")
woodland Woodland @relation(fields: [woodlandId], references: [id])
@@map("woodland_player")
}
Loading

0 comments on commit a64381d

Please sign in to comment.