diff --git a/lib/db/schema/gamePlatformSupport.ts b/lib/db/schema/gamePlatformSupport.ts new file mode 100644 index 0000000..a024350 --- /dev/null +++ b/lib/db/schema/gamePlatformSupport.ts @@ -0,0 +1,61 @@ +import { + boolean, + pgEnum, + pgTable, + text, + timestamp, + unique, +} from "drizzle-orm/pg-core" +import { games } from "./games" +import { hardware } from "./hardware" + +export const protonStatusEnum = pgEnum("proton_status", [ + "native", + "proton", + "unsupported", + "unknown", +]) + +export const antiCheatStatusEnum = pgEnum("anti_cheat_status", [ + "none", + "supported", + "unsupported", + "unknown", +]) + +export const gamePlatformSupport = pgTable( + "game_platform_support", + { + id: text("id") + .primaryKey() + .$defaultFn(() => crypto.randomUUID()), + gameId: text("game_id") + .notNull() + .references(() => games.id, { onDelete: "cascade" }), + hardwareSlug: text("hardware_slug") + .notNull() + .references(() => hardware.slug, { onDelete: "restrict" }), + + // Compatibility + isSupported: boolean("is_supported").default(false).notNull(), + protonStatus: protonStatusEnum("proton_status") + .default("unknown") + .notNull(), + + // Anti-cheat details + antiCheatRelevant: boolean("anti_cheat_relevant") + .default(false) + .notNull(), + antiCheatName: text("anti_cheat_name"), + antiCheatVersion: text("anti_cheat_version"), + antiCheatStatus: antiCheatStatusEnum("anti_cheat_status") + .default("unknown") + .notNull(), + + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at").defaultNow().notNull(), + }, + (table) => [ + unique("game_hardware_unique").on(table.gameId, table.hardwareSlug), + ] +) diff --git a/lib/db/schema/index.ts b/lib/db/schema/index.ts index 3222d42..2d99c03 100644 --- a/lib/db/schema/index.ts +++ b/lib/db/schema/index.ts @@ -2,6 +2,5 @@ export * from "./games" export * from "./gameVersions" export * from "./hardware" -// TODO: uncomment when files are created in Chunk 3 -// export * from "./performanceEntries" -// export * from "./gamePlatformSupport" +export * from "./performanceEntries" +export * from "./gamePlatformSupport" diff --git a/lib/db/schema/performanceEntries.ts b/lib/db/schema/performanceEntries.ts new file mode 100644 index 0000000..7bd4154 --- /dev/null +++ b/lib/db/schema/performanceEntries.ts @@ -0,0 +1,51 @@ +import { + boolean, + jsonb, + pgTable, + real, + text, + timestamp, +} from "drizzle-orm/pg-core" +import { gameVersions } from "./gameVersions" +import { hardware } from "./hardware" + +export const performanceEntries = pgTable("performance_entries", { + id: text("id") + .primaryKey() + .$defaultFn(() => crypto.randomUUID()), + versionId: text("version_id") + .notNull() + .references(() => gameVersions.id, { onDelete: "cascade" }), + hardwareSlug: text("hardware_slug") + .notNull() + .references(() => hardware.slug, { onDelete: "restrict" }), + userId: text("user_id").notNull(), + + // Performance metrics + fpsAvg: real("fps_avg").notNull(), + fpsLow: real("fps_low"), + fpsHigh: real("fps_high"), + + // Environment + protonVersion: text("proton_version"), + osVersion: text("os_version"), + + // Feature flags + isFsrEnabled: boolean("is_fsr_enabled").default(false).notNull(), + isFrameGenEnabled: boolean("is_frame_gen_enabled").default(false).notNull(), + + // Load times (seconds) + loadTimeSsd: real("load_time_ssd"), + loadTimeSd: real("load_time_sd"), + + // Settings & notes + settingsJson: jsonb("settings_json").$type>(), + userNotes: text("user_notes"), + + // Moderation + isRemoved: boolean("is_removed").default(false).notNull(), + removedReason: text("removed_reason"), + + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updated_at").defaultNow().notNull(), +})