feat: create community suggestions table
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
pgEnum,
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/pg-core"
|
||||
import { games } from "./games"
|
||||
import { user } from "./auth"
|
||||
|
||||
export const suggestionStatusEnum = pgEnum("suggestion_status", [
|
||||
"pending",
|
||||
"approved",
|
||||
"rejected",
|
||||
])
|
||||
|
||||
export const communitySuggestions = pgTable(
|
||||
"community_suggestions",
|
||||
{
|
||||
id: text("id")
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
gameId: text("game_id")
|
||||
.notNull()
|
||||
.references(() => games.id, { onDelete: "cascade" }),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
fieldName: text("field_name").notNull(), // e.g. "title", "description", "developer"
|
||||
currentValue: text("current_value"), // current value (snapshot)
|
||||
proposedValue: text("proposed_value").notNull(), // proposed new value
|
||||
reason: text("reason"), // optional explanation
|
||||
status: suggestionStatusEnum("status").default("pending").notNull(),
|
||||
reviewedBy: text("reviewed_by").references(() => user.id),
|
||||
reviewedAt: timestamp("reviewed_at"),
|
||||
reviewNote: text("review_note"), // reviewer's note
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at")
|
||||
.defaultNow()
|
||||
.$onUpdate(() => new Date())
|
||||
.notNull(),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("community_suggestions_game_field_user").on(
|
||||
table.gameId,
|
||||
table.fieldName,
|
||||
table.userId,
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -8,3 +8,4 @@ export * from "./gamePlatformSupport"
|
||||
export * from "./gameComments"
|
||||
export * from "./savedGames"
|
||||
export * from "./reports"
|
||||
export * from "./community-suggestions"
|
||||
|
||||
Reference in New Issue
Block a user