mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Update dependencies, custom tsVector type for drizzle, and adding vector column on game for name and slug, and adding index on the search vector column.
This commit is contained in:
parent
baafd75839
commit
eac53a993b
11 changed files with 2879 additions and 687 deletions
27
drizzle/0002_sour_silverclaw.sql
Normal file
27
drizzle/0002_sour_silverclaw.sql
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
ALTER TABLE "artists" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "artists" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "categories" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "categories" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "collection_items" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "collection_items" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "collections" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "collections" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "designers" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "designers" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "expansions" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "expansions" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "games" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "games" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "mechanics" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "mechanics" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "publishers" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "publishers" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "user_roles" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "user_roles" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "users" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "users" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "wishlist_items" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "wishlist_items" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "wishlists" ALTER COLUMN "created_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "wishlists" ALTER COLUMN "updated_at" SET DEFAULT now();--> statement-breakpoint
|
||||||
|
ALTER TABLE "games" ADD COLUMN "text_searchable_index" "tsvector";
|
||||||
1
drizzle/0003_thick_tinkerer.sql
Normal file
1
drizzle/0003_thick_tinkerer.sql
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
CREATE INDEX IF NOT EXISTS "text_searchable_idx" ON "games" ("text_searchable_index");
|
||||||
1055
drizzle/meta/0002_snapshot.json
Normal file
1055
drizzle/meta/0002_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
1063
drizzle/meta/0003_snapshot.json
Normal file
1063
drizzle/meta/0003_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -15,6 +15,20 @@
|
||||||
"when": 1707438055782,
|
"when": 1707438055782,
|
||||||
"tag": "0001_giant_tomorrow_man",
|
"tag": "0001_giant_tomorrow_man",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 2,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1707524139123,
|
||||||
|
"tag": "0002_sour_silverclaw",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 3,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1707526808124,
|
||||||
|
"tag": "0003_thick_tinkerer",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
12
package.json
12
package.json
|
|
@ -34,7 +34,7 @@
|
||||||
"@sveltejs/kit": "^2.5.0",
|
"@sveltejs/kit": "^2.5.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
||||||
"@types/cookie": "^0.6.0",
|
"@types/cookie": "^0.6.0",
|
||||||
"@types/node": "^20.11.16",
|
"@types/node": "^20.11.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||||
"@typescript-eslint/parser": "^6.21.0",
|
"@typescript-eslint/parser": "^6.21.0",
|
||||||
"autoprefixer": "^10.4.17",
|
"autoprefixer": "^10.4.17",
|
||||||
|
|
@ -47,11 +47,11 @@
|
||||||
"just-debounce-it": "^3.2.0",
|
"just-debounce-it": "^3.2.0",
|
||||||
"postcss": "^8.4.35",
|
"postcss": "^8.4.35",
|
||||||
"postcss-import": "^16.0.0",
|
"postcss-import": "^16.0.0",
|
||||||
"postcss-load-config": "^5.0.2",
|
"postcss-load-config": "^5.0.3",
|
||||||
"postcss-preset-env": "^9.3.0",
|
"postcss-preset-env": "^9.3.0",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"prettier-plugin-svelte": "^3.1.2",
|
"prettier-plugin-svelte": "^3.1.2",
|
||||||
"prisma": "^5.8.1",
|
"prisma": "^5.9.1",
|
||||||
"sass": "^1.70.0",
|
"sass": "^1.70.0",
|
||||||
"satori": "^0.10.13",
|
"satori": "^0.10.13",
|
||||||
"satori-html": "^0.3.2",
|
"satori-html": "^0.3.2",
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
"tslib": "^2.6.1",
|
"tslib": "^2.6.1",
|
||||||
"tsx": "^4.7.0",
|
"tsx": "^4.7.0",
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
"vite": "^5.0.12",
|
"vite": "^5.1.1",
|
||||||
"vitest": "^1.2.2",
|
"vitest": "^1.2.2",
|
||||||
"zod": "^3.22.4"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
|
|
@ -85,8 +85,8 @@
|
||||||
"@lukeed/uuid": "^2.0.1",
|
"@lukeed/uuid": "^2.0.1",
|
||||||
"@neondatabase/serverless": "^0.8.1",
|
"@neondatabase/serverless": "^0.8.1",
|
||||||
"@paralleldrive/cuid2": "^2.2.2",
|
"@paralleldrive/cuid2": "^2.2.2",
|
||||||
"@planetscale/database": "^1.15.0",
|
"@planetscale/database": "^1.16.0",
|
||||||
"@prisma/client": "^5.8.1",
|
"@prisma/client": "^5.9.1",
|
||||||
"@sentry/sveltekit": "^7.100.1",
|
"@sentry/sveltekit": "^7.100.1",
|
||||||
"@sveltejs/adapter-vercel": "^5.1.0",
|
"@sveltejs/adapter-vercel": "^5.1.0",
|
||||||
"@types/feather-icons": "^4.29.4",
|
"@types/feather-icons": "^4.29.4",
|
||||||
|
|
|
||||||
510
pnpm-lock.yaml
510
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let kind = 'primary';
|
export let kind = 'primary';
|
||||||
export let size;
|
|
||||||
export let icon = false;
|
export let icon = false;
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -27,18 +26,4 @@
|
||||||
min-width: 23.5rem;
|
min-width: 23.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.danger {
|
|
||||||
background-color: var(--warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
.danger:hover {
|
|
||||||
background-color: var(--warning-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-icon {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, auto);
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
|
import postgres from 'postgres';
|
||||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||||
import { migrate } from 'drizzle-orm/postgres-js/migrator';
|
import { migrate } from 'drizzle-orm/postgres-js/migrator';
|
||||||
import postgres from 'postgres';
|
|
||||||
|
|
||||||
const connection = postgres({
|
const connection = postgres({
|
||||||
host: process.env.DATABASE_HOST,
|
host: process.env.DATABASE_HOST,
|
||||||
|
|
|
||||||
841
src/schema.ts
841
src/schema.ts
|
|
@ -1,38 +1,40 @@
|
||||||
import { relations, sql, type InferSelectModel } from 'drizzle-orm';
|
import { relations, sql, type InferSelectModel } from 'drizzle-orm';
|
||||||
import { pgTable, timestamp, varchar, boolean, integer, text } from 'drizzle-orm/pg-core';
|
import { pgTable, timestamp, varchar, boolean, integer, text, index } from 'drizzle-orm/pg-core';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
|
import { tsvector } from './tsVector';
|
||||||
|
|
||||||
export const users = pgTable("users", {
|
export const users = pgTable('users', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
|
.primaryKey()
|
||||||
.$defaultFn(() => nanoid()),
|
.$defaultFn(() => nanoid()),
|
||||||
username: varchar("username", {
|
username: varchar('username', {
|
||||||
length: 255
|
length: 255
|
||||||
}).unique(),
|
}).unique(),
|
||||||
hashed_password: varchar("hashed_password", {
|
hashed_password: varchar('hashed_password', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
email: varchar("email", {
|
email: varchar('email', {
|
||||||
length: 255
|
length: 255
|
||||||
}).unique(),
|
}).unique(),
|
||||||
first_name: varchar("first_name", {
|
first_name: varchar('first_name', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
last_name: varchar("last_name", {
|
last_name: varchar('last_name', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
verified: boolean("verified").default(false),
|
verified: boolean('verified').default(false),
|
||||||
receive_email: boolean("receive_email").default(false),
|
receive_email: boolean('receive_email').default(false),
|
||||||
theme: varchar("theme", {
|
theme: varchar('theme', {
|
||||||
length: 255
|
length: 255
|
||||||
}).default("system"),
|
}).default('system'),
|
||||||
created_at: timestamp("created_at").default(sql`(now())`),
|
created_at: timestamp('created_at').default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at").default(sql`(now())`)
|
updated_at: timestamp('updated_at').default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const user_relations = relations(users, ({ many }) => ({
|
export const user_relations = relations(users, ({ many }) => ({
|
||||||
user_roles: many(user_roles)
|
user_roles: many(user_roles)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export type Users = InferSelectModel<typeof users>;
|
export type Users = InferSelectModel<typeof users>;
|
||||||
|
|
@ -48,7 +50,7 @@ export const sessions = pgTable('sessions', {
|
||||||
.references(() => users.id),
|
.references(() => users.id),
|
||||||
expiresAt: timestamp('expires_at', {
|
expiresAt: timestamp('expires_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date"
|
mode: 'date'
|
||||||
}).notNull(),
|
}).notNull(),
|
||||||
ipCountry: varchar('ip_country', {
|
ipCountry: varchar('ip_country', {
|
||||||
length: 255
|
length: 255
|
||||||
|
|
@ -58,243 +60,255 @@ export const sessions = pgTable('sessions', {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const roles = pgTable("roles", {
|
export const roles = pgTable('roles', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}).unique()
|
length: 255
|
||||||
|
}).unique()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const user_roles = pgTable("user_roles", {
|
export const user_roles = pgTable('user_roles', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
user_id: varchar("user_id", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
user_id: varchar('user_id', {
|
||||||
})
|
length: 255
|
||||||
.notNull()
|
})
|
||||||
.references(() => users.id, { onDelete: 'cascade' }),
|
.notNull()
|
||||||
role_id: varchar("role_id", {
|
.references(() => users.id, { onDelete: 'cascade' }),
|
||||||
length: 255
|
role_id: varchar('role_id', {
|
||||||
})
|
length: 255
|
||||||
.notNull()
|
})
|
||||||
.references(() => roles.id, { onDelete: 'cascade' }),
|
.notNull()
|
||||||
created_at: timestamp("created_at", {
|
.references(() => roles.id, { onDelete: 'cascade' }),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const user_role_relations = relations(user_roles, ({ one }) => ({
|
export const user_role_relations = relations(user_roles, ({ one }) => ({
|
||||||
role: one(roles, {
|
role: one(roles, {
|
||||||
fields: [user_roles.role_id],
|
fields: [user_roles.role_id],
|
||||||
references: [roles.id]
|
references: [roles.id]
|
||||||
}),
|
}),
|
||||||
user: one(users, {
|
user: one(users, {
|
||||||
fields: [user_roles.user_id],
|
fields: [user_roles.user_id],
|
||||||
references: [users.id]
|
references: [users.id]
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const games = pgTable("games", {
|
export const games = pgTable('games', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}),
|
length: 255
|
||||||
slug: varchar("slug", {
|
|
||||||
length: 255
|
|
||||||
}),
|
|
||||||
description: text("description"),
|
|
||||||
year_published: integer("year_published"),
|
|
||||||
min_players: integer("min_players"),
|
|
||||||
max_players: integer("max_players"),
|
|
||||||
playtime: integer("playtime"),
|
|
||||||
min_playtime: integer("min_playtime"),
|
|
||||||
max_playtime: integer("max_playtime"),
|
|
||||||
min_age: integer("min_age"),
|
|
||||||
image_url: varchar("image_url", {
|
|
||||||
length: 255
|
|
||||||
}),
|
|
||||||
thumb_url: varchar("thumb_url", {
|
|
||||||
length: 255
|
|
||||||
}),
|
|
||||||
url: varchar("url", {
|
|
||||||
length: 255
|
|
||||||
}),
|
|
||||||
external_id: integer("external_id").unique(),
|
|
||||||
last_sync_at: timestamp("last_sync_at", {
|
|
||||||
withTimezone: true,
|
|
||||||
mode: "date",
|
|
||||||
precision: 6
|
|
||||||
}),
|
}),
|
||||||
created_at: timestamp("created_at", {
|
slug: varchar('slug', {
|
||||||
|
length: 255
|
||||||
|
}),
|
||||||
|
description: text('description'),
|
||||||
|
year_published: integer('year_published'),
|
||||||
|
min_players: integer('min_players'),
|
||||||
|
max_players: integer('max_players'),
|
||||||
|
playtime: integer('playtime'),
|
||||||
|
min_playtime: integer('min_playtime'),
|
||||||
|
max_playtime: integer('max_playtime'),
|
||||||
|
min_age: integer('min_age'),
|
||||||
|
image_url: varchar('image_url', {
|
||||||
|
length: 255
|
||||||
|
}),
|
||||||
|
thumb_url: varchar('thumb_url', {
|
||||||
|
length: 255
|
||||||
|
}),
|
||||||
|
url: varchar('url', {
|
||||||
|
length: 255
|
||||||
|
}),
|
||||||
|
text_searchable_index: tsvector('text_searchable_index'),
|
||||||
|
external_id: integer('external_id').unique(),
|
||||||
|
last_sync_at: timestamp('last_sync_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}),
|
||||||
updated_at: timestamp("updated_at", {
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`),
|
||||||
|
updated_at: timestamp('updated_at', {
|
||||||
|
withTimezone: true,
|
||||||
|
mode: 'date',
|
||||||
|
precision: 6
|
||||||
|
}).default(sql`now()`)
|
||||||
|
}, (table) => {
|
||||||
|
return {
|
||||||
|
text_searchable_idx: index("text_searchable_idx").on(table.text_searchable_index).using(sql`'gin'`)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export type Games = InferSelectModel<typeof games>;
|
export type Games = InferSelectModel<typeof games>;
|
||||||
|
|
||||||
export const gameRelations = relations(games, ({ many }) => ({
|
export const gameRelations = relations(games, ({ many }) => ({
|
||||||
categories_to_games: many(categories_to_games),
|
categories_to_games: many(categories_to_games),
|
||||||
mechanics_to_games: many(mechanics_to_games),
|
mechanics_to_games: many(mechanics_to_games),
|
||||||
designers_to_games: many(designers_to_games),
|
designers_to_games: many(designers_to_games),
|
||||||
publishers_to_games: many(publishers_to_games),
|
publishers_to_games: many(publishers_to_games),
|
||||||
artists_to_games: many(artists_to_games),
|
artists_to_games: many(artists_to_games)
|
||||||
}))
|
|
||||||
|
|
||||||
export const expansions = pgTable("expansions", {
|
|
||||||
id: varchar("id", {
|
|
||||||
length: 255
|
|
||||||
}).primaryKey()
|
|
||||||
.$defaultFn(() => nanoid()),
|
|
||||||
base_game_id: varchar("base_game_id", {
|
|
||||||
length: 255
|
|
||||||
})
|
|
||||||
.notNull()
|
|
||||||
.references(() => games.id, { onDelete: 'cascade' }),
|
|
||||||
game_id: varchar("game_id", {
|
|
||||||
length: 255
|
|
||||||
})
|
|
||||||
.notNull()
|
|
||||||
.references(() => games.id, { onDelete: 'cascade' }),
|
|
||||||
created_at: timestamp("created_at", {
|
|
||||||
withTimezone: true,
|
|
||||||
mode: "date",
|
|
||||||
precision: 6
|
|
||||||
}).default(sql`(now())`),
|
|
||||||
updated_at: timestamp("updated_at", {
|
|
||||||
withTimezone: true,
|
|
||||||
mode: "date",
|
|
||||||
precision: 6
|
|
||||||
}).default(sql`(now())`)
|
|
||||||
})
|
|
||||||
|
|
||||||
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]
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const collections = pgTable("collections", {
|
export const expansions = pgTable('expansions', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
user_id: varchar("user_id", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
base_game_id: varchar('base_game_id', {
|
||||||
})
|
length: 255
|
||||||
.notNull()
|
})
|
||||||
.references(() => users.id, { onDelete: 'cascade' }),
|
.notNull()
|
||||||
created_at: timestamp("created_at", {
|
.references(() => games.id, { onDelete: 'cascade' }),
|
||||||
|
game_id: varchar('game_id', {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.references(() => games.id, { onDelete: 'cascade' }),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
|
});
|
||||||
|
|
||||||
|
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]
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const collections = pgTable('collections', {
|
||||||
|
id: varchar('id', {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.primaryKey()
|
||||||
|
.$defaultFn(() => nanoid()),
|
||||||
|
user_id: varchar('user_id', {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.references(() => users.id, { onDelete: 'cascade' }),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
|
withTimezone: true,
|
||||||
|
mode: 'date',
|
||||||
|
precision: 6
|
||||||
|
}).default(sql`now()`),
|
||||||
|
updated_at: timestamp('updated_at', {
|
||||||
|
withTimezone: true,
|
||||||
|
mode: 'date',
|
||||||
|
precision: 6
|
||||||
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const collection_relations = relations(collections, ({ one }) => ({
|
export const collection_relations = relations(collections, ({ one }) => ({
|
||||||
user: one(users, {
|
user: one(users, {
|
||||||
fields: [collections.user_id],
|
fields: [collections.user_id],
|
||||||
references: [users.id]
|
references: [users.id]
|
||||||
}),
|
})
|
||||||
}))
|
|
||||||
|
|
||||||
export const collection_items = pgTable("collection_items", {
|
|
||||||
id: varchar("id", {
|
|
||||||
length: 255
|
|
||||||
}).primaryKey()
|
|
||||||
.$defaultFn(() => nanoid()),
|
|
||||||
collection_id: varchar("collection_id", {
|
|
||||||
length: 255
|
|
||||||
})
|
|
||||||
.notNull()
|
|
||||||
.references(() => collections.id, { onDelete: 'cascade' }),
|
|
||||||
game_id: varchar("game_id", {
|
|
||||||
length: 255
|
|
||||||
})
|
|
||||||
.notNull()
|
|
||||||
.references(() => games.id, { onDelete: 'cascade' }),
|
|
||||||
created_at: timestamp("created_at", {
|
|
||||||
withTimezone: true,
|
|
||||||
mode: "date",
|
|
||||||
precision: 6
|
|
||||||
}).default(sql`(now())`),
|
|
||||||
updated_at: timestamp("updated_at", {
|
|
||||||
withTimezone: true,
|
|
||||||
mode: "date",
|
|
||||||
precision: 6
|
|
||||||
}).default(sql`(now())`)
|
|
||||||
});
|
|
||||||
|
|
||||||
export const collection_item_relations = relations(collection_items, ({ one }) =>({
|
|
||||||
collection: one(collections, {
|
|
||||||
fields: [collection_items.collection_id],
|
|
||||||
references: [collections.id]
|
|
||||||
}),
|
|
||||||
game: one(games, {
|
|
||||||
fields: [collection_items.game_id],
|
|
||||||
references: [games.id]
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const wishlists = pgTable("wishlists", {
|
export const collection_items = pgTable('collection_items', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
user_id: varchar("user_id", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
collection_id: varchar('collection_id', {
|
||||||
})
|
length: 255
|
||||||
.notNull()
|
})
|
||||||
.references(() => users.id, { onDelete: 'cascade' }),
|
.notNull()
|
||||||
created_at: timestamp("created_at", {
|
.references(() => collections.id, { onDelete: 'cascade' }),
|
||||||
|
game_id: varchar('game_id', {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.references(() => games.id, { onDelete: 'cascade' }),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
|
});
|
||||||
|
|
||||||
|
export const collection_item_relations = relations(collection_items, ({ one }) => ({
|
||||||
|
collection: one(collections, {
|
||||||
|
fields: [collection_items.collection_id],
|
||||||
|
references: [collections.id]
|
||||||
|
}),
|
||||||
|
game: one(games, {
|
||||||
|
fields: [collection_items.game_id],
|
||||||
|
references: [games.id]
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const wishlists = pgTable('wishlists', {
|
||||||
|
id: varchar('id', {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.primaryKey()
|
||||||
|
.$defaultFn(() => nanoid()),
|
||||||
|
user_id: varchar('user_id', {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.references(() => users.id, { onDelete: 'cascade' }),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
|
withTimezone: true,
|
||||||
|
mode: 'date',
|
||||||
|
precision: 6
|
||||||
|
}).default(sql`now()`),
|
||||||
|
updated_at: timestamp('updated_at', {
|
||||||
|
withTimezone: true,
|
||||||
|
mode: 'date',
|
||||||
|
precision: 6
|
||||||
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const wishlists_relations = relations(wishlists, ({ one }) => ({
|
export const wishlists_relations = relations(wishlists, ({ one }) => ({
|
||||||
user: one(users, {
|
user: one(users, {
|
||||||
fields: [wishlists.user_id],
|
fields: [wishlists.user_id],
|
||||||
references: [users.id]
|
references: [users.id]
|
||||||
}),
|
})
|
||||||
}))
|
}));
|
||||||
|
|
||||||
export const wishlist_items = pgTable('wishlist_items', {
|
export const wishlist_items = pgTable('wishlist_items', {
|
||||||
id: varchar('id', {
|
id: varchar('id', {
|
||||||
|
|
@ -314,161 +328,166 @@ export const wishlist_items = pgTable('wishlist_items', {
|
||||||
.references(() => games.id, { onDelete: 'cascade' }),
|
.references(() => games.id, { onDelete: 'cascade' }),
|
||||||
created_at: timestamp('created_at', {
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp('updated_at', {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const wishlist_item_relations = relations(wishlist_items, ({ one }) => ({
|
export const wishlist_item_relations = relations(wishlist_items, ({ one }) => ({
|
||||||
wishlist: one(wishlists, {
|
wishlist: one(wishlists, {
|
||||||
fields: [wishlist_items.wishlist_id],
|
fields: [wishlist_items.wishlist_id],
|
||||||
references: [wishlists.id]
|
references: [wishlists.id]
|
||||||
}),
|
}),
|
||||||
game: one(games, {
|
game: one(games, {
|
||||||
fields: [wishlist_items.game_id],
|
fields: [wishlist_items.game_id],
|
||||||
references: [games.id]
|
references: [games.id]
|
||||||
})
|
})
|
||||||
}))
|
}));
|
||||||
|
|
||||||
export const publishers = pgTable("publishers", {
|
export const publishers = pgTable('publishers', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}),
|
length: 255
|
||||||
slug: varchar("slug", {
|
}),
|
||||||
length: 255
|
slug: varchar('slug', {
|
||||||
}),
|
length: 255
|
||||||
external_id: integer("external_id"),
|
}),
|
||||||
created_at: timestamp("created_at", {
|
external_id: integer('external_id'),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const publishers_relations = relations(publishers, ({ many }) => ({
|
export const publishers_relations = relations(publishers, ({ many }) => ({
|
||||||
publishers_to_games: many(publishers_to_games)
|
publishers_to_games: many(publishers_to_games)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const categories = pgTable("categories", {
|
export const categories = pgTable('categories', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}),
|
length: 255
|
||||||
slug: varchar("slug", {
|
}),
|
||||||
length: 255
|
slug: varchar('slug', {
|
||||||
}),
|
length: 255
|
||||||
external_id: integer("external_id"),
|
}),
|
||||||
created_at: timestamp("created_at", {
|
external_id: integer('external_id'),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const categories_relations = relations(categories, ({ many }) => ({
|
export const categories_relations = relations(categories, ({ many }) => ({
|
||||||
categories_to_games: many(categories_to_games)
|
categories_to_games: many(categories_to_games)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const mechanics = pgTable("mechanics", {
|
export const mechanics = pgTable('mechanics', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}),
|
length: 255
|
||||||
slug: varchar("slug", {
|
}),
|
||||||
length: 255
|
slug: varchar('slug', {
|
||||||
}),
|
length: 255
|
||||||
external_id: integer("external_id"),
|
}),
|
||||||
created_at: timestamp("created_at", {
|
external_id: integer('external_id'),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mechanic_relations = relations(mechanics, ({ many }) => ({
|
export const mechanic_relations = relations(mechanics, ({ many }) => ({
|
||||||
mechanics_to_games: many(mechanics_to_games)
|
mechanics_to_games: many(mechanics_to_games)
|
||||||
}))
|
}));
|
||||||
|
|
||||||
export const designers = pgTable("designers", {
|
export const designers = pgTable('designers', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}),
|
length: 255
|
||||||
slug: varchar("slug", {
|
}),
|
||||||
length: 255
|
slug: varchar('slug', {
|
||||||
}),
|
length: 255
|
||||||
external_id: integer("external_id"),
|
}),
|
||||||
created_at: timestamp("created_at", {
|
external_id: integer('external_id'),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const designers_relations = relations(designers, ({ many }) => ({
|
export const designers_relations = relations(designers, ({ many }) => ({
|
||||||
designers_to_games: many(designers_to_games)
|
designers_to_games: many(designers_to_games)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const artists = pgTable("artists", {
|
export const artists = pgTable('artists', {
|
||||||
id: varchar("id", {
|
id: varchar('id', {
|
||||||
length: 255
|
length: 255
|
||||||
}).primaryKey()
|
})
|
||||||
.$defaultFn(() => nanoid()),
|
.primaryKey()
|
||||||
name: varchar("name", {
|
.$defaultFn(() => nanoid()),
|
||||||
length: 255
|
name: varchar('name', {
|
||||||
}),
|
length: 255
|
||||||
slug: varchar("slug", {
|
}),
|
||||||
length: 255
|
slug: varchar('slug', {
|
||||||
}),
|
length: 255
|
||||||
external_id: integer("external_id"),
|
}),
|
||||||
created_at: timestamp("created_at", {
|
external_id: integer('external_id'),
|
||||||
|
created_at: timestamp('created_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`),
|
}).default(sql`now()`),
|
||||||
updated_at: timestamp("updated_at", {
|
updated_at: timestamp('updated_at', {
|
||||||
withTimezone: true,
|
withTimezone: true,
|
||||||
mode: "date",
|
mode: 'date',
|
||||||
precision: 6
|
precision: 6
|
||||||
}).default(sql`(now())`)
|
}).default(sql`now()`)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const artists_relations = relations(artists, ({ many }) => ({
|
export const artists_relations = relations(artists, ({ many }) => ({
|
||||||
|
|
@ -481,96 +500,96 @@ export const artists_to_games = pgTable('artists_to_games', {
|
||||||
}),
|
}),
|
||||||
game_id: varchar('game_id', {
|
game_id: varchar('game_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const artists_to_games_relations = relations(artists_to_games, ({ one }) => ({
|
export const artists_to_games_relations = relations(artists_to_games, ({ one }) => ({
|
||||||
artist: one(artists, {
|
artist: one(artists, {
|
||||||
fields: [artists_to_games.artist_id],
|
fields: [artists_to_games.artist_id],
|
||||||
references: [artists.id]
|
references: [artists.id]
|
||||||
}),
|
}),
|
||||||
game: one(games, {
|
game: one(games, {
|
||||||
fields: [artists_to_games.game_id],
|
fields: [artists_to_games.game_id],
|
||||||
references: [games.id]
|
references: [games.id]
|
||||||
}),
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const categories_to_games = pgTable("categories_to_games", {
|
export const categories_to_games = pgTable('categories_to_games', {
|
||||||
category_id: varchar("category_id", {
|
category_id: varchar('category_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
game_id: varchar("game_id", {
|
game_id: varchar('game_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const categories_to_games_relations = relations(categories_to_games, ({ one }) => ({
|
export const categories_to_games_relations = relations(categories_to_games, ({ one }) => ({
|
||||||
category: one(categories, {
|
category: one(categories, {
|
||||||
fields: [categories_to_games.category_id],
|
fields: [categories_to_games.category_id],
|
||||||
references: [categories.id]
|
references: [categories.id]
|
||||||
}),
|
}),
|
||||||
game: one(games, {
|
game: one(games, {
|
||||||
fields: [categories_to_games.game_id],
|
fields: [categories_to_games.game_id],
|
||||||
references: [games.id]
|
references: [games.id]
|
||||||
}),
|
})
|
||||||
}))
|
}));
|
||||||
|
|
||||||
export const designers_to_games = pgTable("designers_to_games", {
|
export const designers_to_games = pgTable('designers_to_games', {
|
||||||
designer_id: varchar("designer_id", {
|
designer_id: varchar('designer_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
game_id: varchar("game_id", {
|
game_id: varchar('game_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const designers_to_games_relations = relations(designers_to_games, ({ one }) => ({
|
export const designers_to_games_relations = relations(designers_to_games, ({ one }) => ({
|
||||||
designer: one(designers, {
|
designer: one(designers, {
|
||||||
fields: [designers_to_games.designer_id],
|
fields: [designers_to_games.designer_id],
|
||||||
references: [designers.id]
|
references: [designers.id]
|
||||||
}),
|
}),
|
||||||
game: one(games, {
|
game: one(games, {
|
||||||
fields: [designers_to_games.game_id],
|
fields: [designers_to_games.game_id],
|
||||||
references: [games.id]
|
references: [games.id]
|
||||||
}),
|
})
|
||||||
}))
|
}));
|
||||||
|
|
||||||
export const mechanics_to_games = pgTable("mechanics_to_games", {
|
export const mechanics_to_games = pgTable('mechanics_to_games', {
|
||||||
mechanic_id: varchar("mechanic_id", {
|
mechanic_id: varchar('mechanic_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
game_id: varchar("game_id", {
|
game_id: varchar('game_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const mechanics_to_games_relations = relations(mechanics_to_games, ({ one }) => ({
|
export const mechanics_to_games_relations = relations(mechanics_to_games, ({ one }) => ({
|
||||||
mechanic: one(mechanics, {
|
mechanic: one(mechanics, {
|
||||||
fields: [mechanics_to_games.mechanic_id],
|
fields: [mechanics_to_games.mechanic_id],
|
||||||
references: [mechanics.id]
|
references: [mechanics.id]
|
||||||
}),
|
}),
|
||||||
game: one(games, {
|
game: one(games, {
|
||||||
fields: [mechanics_to_games.game_id],
|
fields: [mechanics_to_games.game_id],
|
||||||
references: [games.id]
|
references: [games.id]
|
||||||
}),
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const publishers_to_games = pgTable("publishers_to_games", {
|
export const publishers_to_games = pgTable('publishers_to_games', {
|
||||||
publisher_id: varchar("publisher_id", {
|
publisher_id: varchar('publisher_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
}),
|
||||||
game_id: varchar("game_id", {
|
game_id: varchar('game_id', {
|
||||||
length: 255
|
length: 255
|
||||||
}),
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export const publishers_to_games_relations = relations(publishers_to_games, ({ one }) => ({
|
export const publishers_to_games_relations = relations(publishers_to_games, ({ one }) => ({
|
||||||
publisher: one(publishers, {
|
publisher: one(publishers, {
|
||||||
fields: [publishers_to_games.publisher_id],
|
fields: [publishers_to_games.publisher_id],
|
||||||
references: [publishers.id]
|
references: [publishers.id]
|
||||||
}),
|
}),
|
||||||
game: one(games, {
|
game: one(games, {
|
||||||
fields: [publishers_to_games.game_id],
|
fields: [publishers_to_games.game_id],
|
||||||
references: [games.id]
|
references: [games.id]
|
||||||
}),
|
})
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
26
src/tsVector.ts
Normal file
26
src/tsVector.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { customType } from 'drizzle-orm/pg-core';
|
||||||
|
|
||||||
|
function genExpWithWeights(input: string[]) {
|
||||||
|
const columnExpressions = input.map((column, index) => {
|
||||||
|
const weight = String.fromCharCode(index + 65);
|
||||||
|
return `setweight(to_tsvector('english', coalesce(${column}, '')), '${weight}')`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return `tsvector GENERATED ALWAYS AS (${columnExpressions.join(' || ')}) STORED`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const tsvector = customType<{
|
||||||
|
data: string;
|
||||||
|
config: { sources: string[]; weighted: boolean };
|
||||||
|
}>({
|
||||||
|
dataType(config) {
|
||||||
|
if (config) {
|
||||||
|
const sources = config.sources.join(" || ' ' || ");
|
||||||
|
return config.weighted
|
||||||
|
? genExpWithWeights(config.sources)
|
||||||
|
: `tsvector generated always as (to_tsvector('english', ${sources})) stored`;
|
||||||
|
} else {
|
||||||
|
return `tsvector`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue