From 3663fc328e57b08eb9d20a4d73591e6c62f7bcf2 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Mon, 5 Feb 2024 23:18:13 -0800 Subject: [PATCH] Fix connecting to localhost mysql version and not use planetscale adapters. --- drizzle.config.ts | 6 +- ...hunderbolt.sql => 0000_true_sugar_man.sql} | 29 +- drizzle/0001_dapper_spiral.sql | 24 -- drizzle/0001_motionless_old_lace.sql | 2 + drizzle/meta/0000_snapshot.json | 133 +++++++- drizzle/meta/0001_snapshot.json | 20 +- drizzle/meta/_journal.json | 10 +- package.json | 3 +- pnpm-lock.yaml | 14 + src/lib/drizzle.ts | 19 +- src/routes/api/game/random/+server.ts | 57 ++-- src/schema.ts | 285 +----------------- 12 files changed, 244 insertions(+), 358 deletions(-) rename drizzle/{0000_smooth_thunderbolt.sql => 0000_true_sugar_man.sql} (91%) delete mode 100644 drizzle/0001_dapper_spiral.sql create mode 100644 drizzle/0001_motionless_old_lace.sql diff --git a/drizzle.config.ts b/drizzle.config.ts index e06904c..3ffe7e3 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -6,6 +6,10 @@ export default defineConfig({ out: './drizzle', driver: 'mysql2', dbCredentials: { - uri: `${process.env.DATABASE_URL}` + host: process.env.DATABASE_HOST || 'localhost', + port: 3306, + user: process.env.DATABASE_USER, + password: process.env.DATABASE_PASSWORD, + database: process.env.DATABASE || 'nut-shells' } }); \ No newline at end of file diff --git a/drizzle/0000_smooth_thunderbolt.sql b/drizzle/0000_true_sugar_man.sql similarity index 91% rename from drizzle/0000_smooth_thunderbolt.sql rename to drizzle/0000_true_sugar_man.sql index d8fa1f7..02b1d66 100644 --- a/drizzle/0000_smooth_thunderbolt.sql +++ b/drizzle/0000_true_sugar_man.sql @@ -8,6 +8,11 @@ CREATE TABLE `artists` ( CONSTRAINT `artists_id` PRIMARY KEY(`id`) ); --> statement-breakpoint +CREATE TABLE `artists_to_games` ( + `artist_id` varchar(255), + `game_id` varchar(255) +); +--> statement-breakpoint CREATE TABLE `categories` ( `id` varchar(255) NOT NULL, `name` varchar(255), @@ -18,6 +23,11 @@ CREATE TABLE `categories` ( CONSTRAINT `categories_id` PRIMARY KEY(`id`) ); --> statement-breakpoint +CREATE TABLE `categories_to_games` ( + `category_id` varchar(255), + `game_id` varchar(255) +); +--> statement-breakpoint CREATE TABLE `collection_items` ( `id` varchar(255) NOT NULL, `collection_id` varchar(255) NOT NULL, @@ -45,6 +55,11 @@ CREATE TABLE `designers` ( CONSTRAINT `designers_id` PRIMARY KEY(`id`) ); --> statement-breakpoint +CREATE TABLE `designers_to_games` ( + `designer_id` varchar(255), + `game_id` varchar(255) +); +--> statement-breakpoint CREATE TABLE `expansions` ( `id` varchar(255) NOT NULL, `base_game_id` varchar(255) NOT NULL, @@ -87,6 +102,11 @@ CREATE TABLE `mechanics` ( CONSTRAINT `mechanics_id` PRIMARY KEY(`id`) ); --> statement-breakpoint +CREATE TABLE `mechanics_to_games` ( + `mechanic_id` varchar(255), + `game_id` varchar(255) +); +--> statement-breakpoint CREATE TABLE `publishers` ( `id` varchar(255) NOT NULL, `name` varchar(255), @@ -97,6 +117,11 @@ CREATE TABLE `publishers` ( CONSTRAINT `publishers_id` PRIMARY KEY(`id`) ); --> statement-breakpoint +CREATE TABLE `publishers_to_games` ( + `publisher_id` varchar(255), + `game_id` varchar(255) +); +--> statement-breakpoint CREATE TABLE `roles` ( `id` varchar(255) NOT NULL, `name` varchar(255), @@ -107,8 +132,6 @@ CREATE TABLE `roles` ( CREATE TABLE `sessions` ( `id` varchar(255) NOT NULL, `user_id` varchar(255) NOT NULL, - `ip_country` varchar(255), - `ip_address` varchar(255), `expires_at` datetime NOT NULL, CONSTRAINT `sessions_id` PRIMARY KEY(`id`) ); @@ -161,7 +184,7 @@ ALTER TABLE `collection_items` ADD CONSTRAINT `collection_items_game_id_games_id ALTER TABLE `collections` ADD CONSTRAINT `collections_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE `expansions` ADD CONSTRAINT `expansions_base_game_id_games_id_fk` FOREIGN KEY (`base_game_id`) REFERENCES `games`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE `expansions` ADD CONSTRAINT `expansions_game_id_games_id_fk` FOREIGN KEY (`game_id`) REFERENCES `games`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE `user_roles` ADD CONSTRAINT `user_roles_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE `user_roles` ADD CONSTRAINT `user_roles_role_id_roles_id_fk` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE `wishlist_items` ADD CONSTRAINT `wishlist_items_wishlist_id_wishlists_id_fk` FOREIGN KEY (`wishlist_id`) REFERENCES `wishlists`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint diff --git a/drizzle/0001_dapper_spiral.sql b/drizzle/0001_dapper_spiral.sql deleted file mode 100644 index efd59eb..0000000 --- a/drizzle/0001_dapper_spiral.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE `artists_to_games` ( - `artist_id` varchar(255), - `game_id` varchar(255) -); ---> statement-breakpoint -CREATE TABLE `categories_to_games` ( - `category_id` varchar(255), - `game_id` varchar(255) -); ---> statement-breakpoint -CREATE TABLE `designers_to_games` ( - `designer_id` varchar(255), - `game_id` varchar(255) -); ---> statement-breakpoint -CREATE TABLE `mechanics_to_games` ( - `mechanic_id` varchar(255), - `game_id` varchar(255) -); ---> statement-breakpoint -CREATE TABLE `publishers_to_games` ( - `publisher_id` varchar(255), - `game_id` varchar(255) -); diff --git a/drizzle/0001_motionless_old_lace.sql b/drizzle/0001_motionless_old_lace.sql new file mode 100644 index 0000000..a0f73ea --- /dev/null +++ b/drizzle/0001_motionless_old_lace.sql @@ -0,0 +1,2 @@ +ALTER TABLE `sessions` ADD `ip_country` varchar(255);--> statement-breakpoint +ALTER TABLE `sessions` ADD `ip_address` varchar(255); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json index 40431d3..25c0fa1 100644 --- a/drizzle/meta/0000_snapshot.json +++ b/drizzle/meta/0000_snapshot.json @@ -1,7 +1,7 @@ { "version": "5", "dialect": "mysql", - "id": "4a97ddeb-b977-401f-ad10-a4ae738d1254", + "id": "d90c2144-2349-4a3f-b4f3-87b5ab209936", "prevId": "00000000-0000-0000-0000-000000000000", "tables": { "artists": { @@ -64,6 +64,29 @@ }, "uniqueConstraints": {} }, + "artists_to_games": { + "name": "artists_to_games", + "columns": { + "artist_id": { + "name": "artist_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "game_id": { + "name": "game_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, "categories": { "name": "categories", "columns": { @@ -124,6 +147,29 @@ }, "uniqueConstraints": {} }, + "categories_to_games": { + "name": "categories_to_games", + "columns": { + "category_id": { + "name": "category_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "game_id": { + "name": "game_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, "collection_items": { "name": "collection_items", "columns": { @@ -324,6 +370,29 @@ }, "uniqueConstraints": {} }, + "designers_to_games": { + "name": "designers_to_games", + "columns": { + "designer_id": { + "name": "designer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "game_id": { + "name": "game_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, "expansions": { "name": "expansions", "columns": { @@ -615,6 +684,29 @@ }, "uniqueConstraints": {} }, + "mechanics_to_games": { + "name": "mechanics_to_games", + "columns": { + "mechanic_id": { + "name": "mechanic_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "game_id": { + "name": "game_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, "publishers": { "name": "publishers", "columns": { @@ -675,6 +767,29 @@ }, "uniqueConstraints": {} }, + "publishers_to_games": { + "name": "publishers_to_games", + "columns": { + "publisher_id": { + "name": "publisher_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "game_id": { + "name": "game_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, "roles": { "name": "roles", "columns": { @@ -729,20 +844,6 @@ "notNull": true, "autoincrement": false }, - "ip_country": { - "name": "ip_country", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "ip_address": { - "name": "ip_address", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, "expires_at": { "name": "expires_at", "type": "datetime", @@ -763,7 +864,7 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "no action", "onUpdate": "no action" } }, diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json index 08fc2ae..a2e47bf 100644 --- a/drizzle/meta/0001_snapshot.json +++ b/drizzle/meta/0001_snapshot.json @@ -1,8 +1,8 @@ { "version": "5", "dialect": "mysql", - "id": "ab7f5925-a7ee-4cc4-8def-045d0cb29d75", - "prevId": "4a97ddeb-b977-401f-ad10-a4ae738d1254", + "id": "ede125d1-2fb9-4212-9c56-eeabe6af2332", + "prevId": "d90c2144-2349-4a3f-b4f3-87b5ab209936", "tables": { "artists": { "name": "artists", @@ -844,6 +844,13 @@ "notNull": true, "autoincrement": false }, + "expires_at": { + "name": "expires_at", + "type": "datetime", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, "ip_country": { "name": "ip_country", "type": "varchar(255)", @@ -857,13 +864,6 @@ "primaryKey": false, "notNull": false, "autoincrement": false - }, - "expires_at": { - "name": "expires_at", - "type": "datetime", - "primaryKey": false, - "notNull": true, - "autoincrement": false } }, "indexes": {}, @@ -878,7 +878,7 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "no action", "onUpdate": "no action" } }, diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index eb701c4..25f6af7 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -1,19 +1,19 @@ { "version": "5", - "dialect": "pg", + "dialect": "mysql", "entries": [ { "idx": 0, "version": "5", - "when": 1707012854588, - "tag": "0000_smooth_thunderbolt", + "when": 1707197486310, + "tag": "0000_true_sugar_man", "breakpoints": true }, { "idx": 1, "version": "5", - "when": 1707097761920, - "tag": "0001_dapper_spiral", + "when": 1707199636963, + "tag": "0001_motionless_old_lace", "breakpoints": true } ] diff --git a/package.json b/package.json index b5d132e..036f9cd 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "site:update": "pnpm update -i -L", "generate": "drizzle-kit generate:mysql", "migrate": "tsx ./src/migrate.ts", - "db:push": "drizzle-kit push:mysql" + "push": "drizzle-kit push:mysql" }, "prisma": { "seed": "node --loader ts-node/esm prisma/seed.ts" @@ -64,6 +64,7 @@ "tailwindcss": "^3.4.1", "ts-node": "^10.9.2", "tslib": "^2.6.1", + "tsx": "^4.7.0", "typescript": "^5.3.3", "vite": "^5.0.12", "vitest": "^1.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e759db2..9d91880 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -241,6 +241,9 @@ devDependencies: tslib: specifier: ^2.6.1 version: 2.6.2 + tsx: + specifier: ^4.7.0 + version: 4.7.0 typescript: specifier: ^5.3.3 version: 5.3.3 @@ -6821,6 +6824,17 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + /tsx@4.7.0: + resolution: {integrity: sha512-I+t79RYPlEYlHn9a+KzwrvEwhJg35h/1zHsLC2JXvhC2mdynMv6Zxzvhv5EMV6VF5qJlLlkSnMVvdZV3PSIGcg==} + engines: {node: '>=18.0.0'} + hasBin: true + dependencies: + esbuild: 0.19.11 + get-tsconfig: 4.7.2 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} diff --git a/src/lib/drizzle.ts b/src/lib/drizzle.ts index 15d2cd4..9416f87 100644 --- a/src/lib/drizzle.ts +++ b/src/lib/drizzle.ts @@ -1,13 +1,18 @@ -import { drizzle } from "drizzle-orm/planetscale-serverless"; -import { connect } from "@planetscale/database"; +import { drizzle } from 'drizzle-orm/mysql2'; +import mysql from 'mysql2/promise'; +import { DATABASE_USER, DATABASE_PASSWORD, DATABASE_HOST, DATABASE_DB } from '$env/static/private'; + +console.log('DATABASE_URL', process.env.DATABASE_URL); // create the connection -const connection = connect({ - host: process.env["DATABASE_HOST"], - username: process.env["DATABASE_USERNAME"], - password: process.env["DATABASE_PASSWORD"], +const connection = await mysql.createConnection({ + user: DATABASE_USER, + password: DATABASE_PASSWORD, + host: DATABASE_HOST, + port: 3306, + database: DATABASE_DB }); const db = drizzle(connection); -export default db; \ No newline at end of file +export default db; diff --git a/src/routes/api/game/random/+server.ts b/src/routes/api/game/random/+server.ts index f902ff0..cb4adb2 100644 --- a/src/routes/api/game/random/+server.ts +++ b/src/routes/api/game/random/+server.ts @@ -1,6 +1,8 @@ -import prisma from '$lib/prisma.js'; -import type { Game } from '@prisma/client'; +// import prisma from '$lib/prisma.js'; +import db from '$lib/drizzle.js'; import { error, json } from '@sveltejs/kit'; +import { asc, inArray, sql } from 'drizzle-orm'; +import { games, type Games } from '../../../../schema.js'; export const GET = async ({ url, locals }) => { const searchParams = Object.fromEntries(url.searchParams); @@ -10,22 +12,37 @@ export const GET = async ({ url, locals }) => { error(400, { message: 'Limit must be between 1 and 6' }); } - const totalGames = await prisma.game.count(); - const randomIndex = Math.floor(Math.random() * totalGames); - const ids: { id: string }[] = await prisma.$queryRaw` - SELECT id - FROM games - ORDER BY id - LIMIT ${limit} - OFFSET ${randomIndex} - `; - const randomGames: Game[] = await prisma.game.findMany({ - where: { - id: { - in: ids.map(id => id.id) - } - } - }); - - return json(randomGames); + // const totalGames = await prisma.game.count(); + try { + console.log('db', db); + const dbGames = await db.select({ + count: sql`cast(count(*) as int))`, + }).from(games); + console.log('count', dbGames[0].count); + const randomIndex = Math.floor(Math.random() * dbGames[0]?.count); + const ids = await db.select({ id: games.id }) + .from(games) + .orderBy(asc(games.id)) + .limit(limit) + .offset(randomIndex); + // const ids: { id: string }[] = await prisma.$queryRaw` + // SELECT id + // FROM games + // ORDER BY id + // LIMIT ${limit} + // OFFSET ${randomIndex} + // `; + const randomGames: Games[] = await db.select().from(games).where(inArray(games.id, ids)); + return json(randomGames); + } catch (e) { + console.error(e); + throw error(500, { message: 'Something went wrong' }); + } + // const randomGames: Game[] = await prisma.game.findMany({ + // where: { + // id: { + // in: ids.map(id => id.id) + // } + // } + // }); } \ No newline at end of file diff --git a/src/schema.ts b/src/schema.ts index 279c298..734ef76 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,28 +1,7 @@ -import { relations, sql } from 'drizzle-orm'; -import { mysqlTable, datetime, varchar, boolean, timestamp, year, int, text } from 'drizzle-orm/mysql-core'; +import { relations, sql, type InferSelectModel } from 'drizzle-orm'; +import { mysqlTable, datetime, varchar, boolean, year, int, text } from 'drizzle-orm/mysql-core'; import { nanoid } from 'nanoid'; -// model User { -// id String @id @default(cuid()) -// username String @unique -// hashed_password String? -// email String? @unique -// firstName String? -// lastName String? -// roles UserRole[] -// verified Boolean @default(false) -// receiveEmail Boolean @default(false) -// collection Collection? -// wishlist Wishlist? -// list List[] -// theme String @default("system") -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) -// sessions Session[] - -// @@map("users") -// } - export const users = mysqlTable("users", { id: varchar("id", { length: 255 @@ -56,45 +35,26 @@ export const user_relations = relations(users, ({ many }) => ({ user_roles: many(user_roles) })); -// model Session { -// id String @id @unique -// userId String -// ip_country String -// ip_address String -// expiresAt DateTime -// user User @relation(references: [id], fields: [userId], onDelete: Cascade) +export type Users = InferSelectModel; -// @@index([userId]) -// @@map("sessions") -// } - -export const sessions = mysqlTable("sessions", { - id: varchar("id", { +export const sessions = mysqlTable('sessions', { + id: varchar('id', { length: 255 - }).primaryKey() - .$defaultFn(() => nanoid()), - userId: varchar("user_id", { + }).primaryKey(), + userId: varchar('user_id', { length: 255 }) .notNull() - .references(() => users.id, { onDelete: 'cascade' }), - ipCountry: varchar("ip_country", { + .references(() => users.id), + expiresAt: datetime('expires_at').notNull(), + ipCountry: varchar('ip_country', { length: 255 }), - ipAddress: varchar("ip_address", { + ipAddress: varchar('ip_address', { length: 255 - }), - expiresAt: datetime("expires_at").notNull() + }) }); -// model Role { -// id String @id @default(cuid()) -// name String @unique -// userRoles UserRole[] - -// @@map("roles") -// } - export const roles = mysqlTable("roles", { id: varchar("id", { length: 255 @@ -105,21 +65,6 @@ export const roles = mysqlTable("roles", { }).unique() }); -// model UserRole { -// id String @id @default(cuid()) -// user User @relation(fields: [user_id], references: [id]) -// user_id String -// role Role @relation(fields: [role_id], references: [id]) -// role_id String -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@unique([user_id, role_id]) -// @@index([user_id]) -// @@index([role_id]) -// @@map("user_roles") -// } - export const user_roles = mysqlTable("user_roles", { id: varchar("id", { length: 255 @@ -150,43 +95,6 @@ export const user_role_relations = relations(user_roles, ({ one }) => ({ }) })); -// model Game { -// id String @id @default(cuid()) -// name String -// slug String -// description String? @db.LongText -// year_published Int? @db.Year -// min_players Int? -// max_players Int? -// playtime Int? -// min_playtime Int? -// max_playtime Int? -// min_age Int? -// image_url String? -// thumb_url String? -// url String? -// rules_url String? -// categories Category[] -// mechanics Mechanic[] -// designers Designer[] -// publishers Publisher[] -// artists Artist[] -// names GameName[] -// expansions Expansion[] @relation("BaseToExpansion") -// expansion_of Expansion[] @relation("ExpansionToBase") -// collection_items CollectionItem[] -// wishlist_items WishlistItem[] -// list_items ListItem[] -// external_id Int @unique -// last_sync_at DateTime? @db.Timestamp(6) -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@fulltext([name]) -// @@fulltext([slug]) -// @@map("games") -// } - export const games = mysqlTable("games", { id: varchar("id", { length: 255 @@ -221,6 +129,8 @@ export const games = mysqlTable("games", { updatedAt: datetime("updated_at").default(sql`(now(6))`) }); +export type Games = InferSelectModel; + export const gameRelations = relations(games, ({ many }) => ({ categories_to_games: many(categories_to_games), mechanics_to_games: many(mechanics_to_games), @@ -229,20 +139,6 @@ export const gameRelations = relations(games, ({ many }) => ({ artists_to_games: many(artists_to_games), })) -// model Expansion { -// id String @id @default(cuid()) -// base_game Game @relation(name: "BaseToExpansion", fields: [base_game_id], references: [id]) -// base_game_id String -// game Game @relation(name: "ExpansionToBase", fields: [game_id], references: [id]) -// game_id String -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@index([base_game_id]) -// @@index([game_id]) -// @@map("expansions") -// } - export const expansions = mysqlTable("expansions", { id: varchar("id", { length: 255 @@ -273,16 +169,6 @@ export const expansion_relations = relations(expansions, ({ one }) => ({ }) })); -// model Collection { -// id String @id @default(cuid()) -// user_id String @unique -// user User @relation(references: [id], fields: [user_id]) -// items CollectionItem[] - -// @@index([user_id]) -// @@map("collections") -// } - export const collections = mysqlTable("collections", { id: varchar("id", { length: 255 @@ -304,20 +190,6 @@ export const collection_relations = relations(collections, ({ one }) => ({ }), })) -// model CollectionItem { -// id String @id @default(cuid()) -// collection_id String -// collection Collection @relation(references: [id], fields: [collection_id], onDelete: Cascade) -// game_id String @unique -// game Game @relation(references: [id], fields: [game_id]) -// times_played Int - -// @@index([game_id, collection_id]) -// @@index([game_id]) -// @@index([collection_id]) -// @@map("collection_items") -// } - export const collection_items = mysqlTable("collection_items", { id: varchar("id", { length: 255 @@ -348,16 +220,6 @@ export const collection_item_relations = relations(collection_items, ({ one }) = }) })); -// model Wishlist { -// id String @id @default(cuid()) -// user_id String @unique -// user User @relation(references: [id], fields: [user_id]) -// items WishlistItem[] - -// @@index([user_id]) -// @@map("wishlists") -// } - export const wishlists = mysqlTable("wishlists", { id: varchar("id", { length: 255 @@ -379,21 +241,6 @@ export const wishlists_relations = relations(wishlists, ({ one }) => ({ }), })) -// model WishlistItem { -// id String @id @default(cuid()) -// wishlist_id String -// wishlist Wishlist @relation(references: [id], fields: [wishlist_id], onDelete: Cascade) -// game_id String @unique -// game Game @relation(references: [id], fields: [game_id]) -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@index([game_id, wishlist_id]) -// @@index([game_id]) -// @@index([wishlist_id]) -// @@map("wishlist_items") -// } - export const wishlist_items = mysqlTable('wishlist_items', { id: varchar('id', { length: 255 @@ -425,58 +272,6 @@ export const wishlist_item_relations = relations(wishlist_items, ({ one }) => ({ }) })) -// model List { -// id String @id @default(cuid()) -// name String -// user_id String @unique -// user User @relation(references: [id], fields: [user_id]) -// items ListItem[] - -// @@index([user_id]) -// @@map("lists") -// } - -// model ListItem { -// id String @id @default(cuid()) -// list_id String -// list List @relation(references: [id], fields: [list_id], onDelete: Cascade) -// game_id String @unique -// game Game @relation(references: [id], fields: [game_id]) -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@index([game_id, list_id]) -// @@index([game_id]) -// @@index([list_id]) -// @@map("list_items") -// } - -// model GameName { -// id String @id @default(cuid()) -// name String -// slug String -// game_id String -// game Game @relation(references: [id], fields: [game_id]) -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@index([game_id]) -// @@map("game_names") -// } - -// model Publisher { -// id String @id @default(cuid()) -// name String -// slug String -// external_id Int @unique -// games Game[] -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@fulltext([name]) -// @@map("publishers") -// } - export const publishers = mysqlTable("publishers", { id: varchar("id", { length: 255 @@ -497,19 +292,6 @@ export const publishers_relations = relations(publishers, ({ many }) => ({ publishers_to_games: many(publishers_to_games) })); -// model Category { -// id String @id @default(cuid()) -// name String -// slug String -// games Game[] -// external_id Int @unique -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@fulltext([name]) -// @@map("categories") -// } - export const categories = mysqlTable("categories", { id: varchar("id", { length: 255 @@ -530,19 +312,6 @@ export const categories_relations = relations(categories, ({ many }) => ({ categories_to_games: many(categories_to_games) })); -// model Mechanic { -// id String @id @default(cuid()) -// name String -// slug String -// games Game[] -// external_id Int @unique -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@fulltext([name]) -// @@map("mechanics") -// } - export const mechanics = mysqlTable("mechanics", { id: varchar("id", { length: 255 @@ -563,19 +332,6 @@ export const mechanic_relations = relations(mechanics, ({ many }) => ({ mechanics_to_games: many(mechanics_to_games) })) -// model Designer { -// id String @id @default(cuid()) -// name String -// slug String -// external_id Int @unique -// games Game[] -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@fulltext([name]) -// @@map("designers") -// } - export const designers = mysqlTable("designers", { id: varchar("id", { length: 255 @@ -596,19 +352,6 @@ export const designers_relations = relations(designers, ({ many }) => ({ designers_to_games: many(designers_to_games) })); -// model Artist { -// id String @id @default(cuid()) -// name String -// slug String @unique -// external_id Int @unique -// games Game[] -// created_at DateTime @default(now()) @db.Timestamp(6) -// updated_at DateTime @updatedAt @db.Timestamp(6) - -// @@fulltext([name]) -// @@map("artists") -// } - export const artists = mysqlTable("artists", { id: varchar("id", { length: 255