Skip to content

Commit

Permalink
Changed schemas of "game", "guild", "player" and "template" tables
Browse files Browse the repository at this point in the history
  • Loading branch information
raphdcst committed Jun 12, 2024
1 parent e65ca80 commit 3dacc85
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
15 changes: 7 additions & 8 deletions src/tables/game.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import * as app from "#app"
import { UUID } from "crypto"
import { Player } from "#tables/player.ts"

export interface Game<Player> {
_id: UUID
export interface Game {
_id: string
gameId: string
running: boolean
lap: number
"created_at": number
players: Player[]
players: Pick<Player, "_id">[]
}

export default new app.Table<Game<Player>>({
export default new app.Table<Game>({
name: "game",
setup: (table) => {
table.uuid("_id", { primaryKey: true })
table.string("_id").primary()
table.string("gameId").notNullable()
table.boolean("running").defaultTo(true)
table.integer("lap").defaultTo(1)
table.integer('created_at')
table.jsonb("players").notNullable()
table.bigInteger('created_at')
table.jsonb("players").defaultTo([])
},
})
5 changes: 2 additions & 3 deletions src/tables/guild.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import * as app from "#app"
import { UUID } from "crypto"

export interface Guild {
_id: UUID
_id: string
id: number
prefix: string | null
}

export default new app.Table<Guild>({
name: "guild",
setup: (table) => {
table.uuid("_id", { primaryKey: true })
table.string("_id").primary()
table.bigInteger("id").unique().notNullable()
table.string("prefix")
},
Expand Down
8 changes: 5 additions & 3 deletions src/tables/player.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import * as app from "#app"
import { UUID } from "crypto"
import { Game } from "#tables/game.ts"

export interface Player {
_id: UUID
_id: string
discordId: number
// role: number | undefined
alive: boolean
games: Pick<Game, "_id">[]
}

export default new app.Table<Player>({
name: "player",
setup: (table) => {
table.uuid("_id", { primaryKey: true })
table.string("_id").primary()
table.bigInteger("discordId").unique().notNullable()
// table.integer("role").references("id").inTable("role")
table.boolean("alive").defaultTo(true)
table.jsonb("games").defaultTo([])
},
})
2 changes: 1 addition & 1 deletion src/tables/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface Template {
export default new app.Table<Template>({
name: "template",
setup: (table) => {
table.uuid("_id", { primaryKey: true })
table.increments("_id", { primaryKey: true }).unsigned()
table.string("name").notNullable().unique()
table.integer("Infect Pere Des Loups").defaultTo(0)
table.integer("Loup Garou Voyant").defaultTo(0)
Expand Down

0 comments on commit 3dacc85

Please sign in to comment.