mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Merge branch 'master' of github.com:BradNut/boredgame into development
This commit is contained in:
commit
65e10ed8e1
4 changed files with 82 additions and 0 deletions
|
|
@ -5,7 +5,11 @@ import { defineConfig } from 'drizzle-kit'
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
dialect: 'postgresql',
|
dialect: 'postgresql',
|
||||||
out: './src/lib/server/api/databases/migrations',
|
out: './src/lib/server/api/databases/migrations',
|
||||||
|
<<<<<<< HEAD
|
||||||
schema: './src/lib/server/api/databases/tables/*.table.ts',
|
schema: './src/lib/server/api/databases/tables/*.table.ts',
|
||||||
|
=======
|
||||||
|
schema: './src/lib/server/api/databases/tables/index.ts',
|
||||||
|
>>>>>>> 5849219833a6b9a99ec24a960962c4c537e93748
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
host: env.DATABASE_HOST || 'localhost',
|
host: env.DATABASE_HOST || 'localhost',
|
||||||
port: Number(env.DATABASE_PORT) || 5432,
|
port: Number(env.DATABASE_PORT) || 5432,
|
||||||
|
|
|
||||||
32
src/lib/server/api/databases/tables/expansions.ts
Normal file
32
src/lib/server/api/databases/tables/expansions.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { createId as cuid2 } from '@paralleldrive/cuid2'
|
||||||
|
import { type InferSelectModel, relations } from 'drizzle-orm'
|
||||||
|
import { pgTable, text, uuid } from 'drizzle-orm/pg-core'
|
||||||
|
import { timestamps } from '../../common/utils/table.utils'
|
||||||
|
import { games } from './games'
|
||||||
|
|
||||||
|
export const expansions = pgTable('expansions', {
|
||||||
|
id: uuid('id').primaryKey().defaultRandom(),
|
||||||
|
cuid: text('cuid')
|
||||||
|
.unique()
|
||||||
|
.$defaultFn(() => cuid2()),
|
||||||
|
base_game_id: uuid('base_game_id')
|
||||||
|
.notNull()
|
||||||
|
.references(() => games.id, { onDelete: 'restrict', onUpdate: 'cascade' }),
|
||||||
|
game_id: uuid('game_id')
|
||||||
|
.notNull()
|
||||||
|
.references(() => games.id, { onDelete: 'restrict', onUpdate: 'cascade' }),
|
||||||
|
...timestamps,
|
||||||
|
})
|
||||||
|
|
||||||
|
export type Expansions = InferSelectModel<typeof expansions>
|
||||||
|
|
||||||
|
export const expansion_relations = relations(expansions, ({ one }) => ({
|
||||||
|
baseGame: one(games, {
|
||||||
|
fields: [expansions.base_game_id],
|
||||||
|
references: [games.id],
|
||||||
|
}),
|
||||||
|
game: one(games, {
|
||||||
|
fields: [expansions.game_id],
|
||||||
|
references: [games.id],
|
||||||
|
}),
|
||||||
|
}))
|
||||||
23
src/lib/server/api/databases/tables/mechanics.ts
Normal file
23
src/lib/server/api/databases/tables/mechanics.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { timestamps } from '../../common/utils/table.utils'
|
||||||
|
import { createId as cuid2 } from '@paralleldrive/cuid2'
|
||||||
|
import { type InferSelectModel, relations } from 'drizzle-orm'
|
||||||
|
import { pgTable, text, uuid } from 'drizzle-orm/pg-core'
|
||||||
|
import { mechanicsToExternalIds } from './mechanicsToExternalIds'
|
||||||
|
import { mechanics_to_games } from './mechanicsToGames'
|
||||||
|
|
||||||
|
export const mechanics = pgTable('mechanics', {
|
||||||
|
id: uuid('id').primaryKey().defaultRandom(),
|
||||||
|
cuid: text('cuid')
|
||||||
|
.unique()
|
||||||
|
.$defaultFn(() => cuid2()),
|
||||||
|
name: text('name'),
|
||||||
|
slug: text('slug'),
|
||||||
|
...timestamps,
|
||||||
|
})
|
||||||
|
|
||||||
|
export type Mechanics = InferSelectModel<typeof mechanics>
|
||||||
|
|
||||||
|
export const mechanics_relations = relations(mechanics, ({ many }) => ({
|
||||||
|
mechanics_to_games: many(mechanics_to_games),
|
||||||
|
mechanicsToExternalIds: many(mechanicsToExternalIds),
|
||||||
|
}))
|
||||||
23
src/lib/server/api/databases/tables/publishers.ts
Normal file
23
src/lib/server/api/databases/tables/publishers.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { timestamps } from '../../common/utils/table.utils'
|
||||||
|
import { createId as cuid2 } from '@paralleldrive/cuid2'
|
||||||
|
import { type InferSelectModel, relations } from 'drizzle-orm'
|
||||||
|
import { pgTable, text, uuid } from 'drizzle-orm/pg-core'
|
||||||
|
import { publishersToExternalIds } from './publishersToExternalIds'
|
||||||
|
import { publishers_to_games } from './publishersToGames'
|
||||||
|
|
||||||
|
export const publishers = pgTable('publishers', {
|
||||||
|
id: uuid('id').primaryKey().defaultRandom(),
|
||||||
|
cuid: text('cuid')
|
||||||
|
.unique()
|
||||||
|
.$defaultFn(() => cuid2()),
|
||||||
|
name: text('name'),
|
||||||
|
slug: text('slug'),
|
||||||
|
...timestamps,
|
||||||
|
})
|
||||||
|
|
||||||
|
export type Publishers = InferSelectModel<typeof publishers>
|
||||||
|
|
||||||
|
export const publishers_relations = relations(publishers, ({ many }) => ({
|
||||||
|
publishers_to_games: many(publishers_to_games),
|
||||||
|
publishersToExternalIds: many(publishersToExternalIds),
|
||||||
|
}))
|
||||||
Loading…
Reference in a new issue