45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { integer, pgTable, varchar, uuid, timestamp, pgEnum } from "drizzle-orm/pg-core";
|
|
|
|
export const guestBook = pgTable("guestBook", {
|
|
id: integer().primaryKey().generatedAlwaysAsIdentity(),
|
|
name: varchar({ length: 255 }).notNull(),
|
|
email: varchar({ length: 255 }).notNull().unique(),
|
|
});
|
|
|
|
// Fantasy League Tables
|
|
export const seasonStatusEnum = pgEnum("season_status", [
|
|
"pre_draft",
|
|
"draft",
|
|
"active",
|
|
"completed",
|
|
]);
|
|
|
|
export const leagues = pgTable("leagues", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
name: varchar("name", { length: 255 }).notNull(),
|
|
createdBy: varchar("created_by", { length: 255 }).notNull(), // Clerk user ID
|
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
});
|
|
|
|
export const seasons = pgTable("seasons", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
leagueId: uuid("league_id")
|
|
.notNull()
|
|
.references(() => leagues.id, { onDelete: "cascade" }),
|
|
year: integer("year").notNull(),
|
|
status: seasonStatusEnum("status").notNull().default("pre_draft"),
|
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
});
|
|
|
|
export const teams = pgTable("teams", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
seasonId: uuid("season_id")
|
|
.notNull()
|
|
.references(() => seasons.id, { onDelete: "cascade" }),
|
|
name: varchar("name", { length: 255 }).notNull(),
|
|
ownerId: varchar("owner_id", { length: 255 }), // Clerk user ID, nullable
|
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
});
|