export const meetings = pgTable(
"meeting",
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 256 }),
isEvent: boolean("isEvent").notNull().default(false),
location: varchar("location", { length: 256 }),
isPublic: boolean("isPublic").notNull().default(false),
isRequired: boolean("isRequired").notNull().default(false),
link: text("link"),
date: date("date", {
mode: "date",
}).notNull(),
createdById: varchar("createdById", { length: 255 })
.notNull(),
createdAt: timestamp("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt"),
},
(example) => ({
createdByIdIdx: index("userCreatedBy_idx").on(example.createdById),
nameIndex: index("name_idx").on(example.name),
dateIndex: index("date_idx").on(example.date),
})
);
export const attendedMeetings = pgTable(
"attended_meetings",
{
userId: varchar("userId", { length: 255 })
.notNull()
.references(() => users.id),
meetingId: integer("meetingId")
.notNull()
.references(() => meetings.id),
createdAt: timestamp("created_at")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
},
(example) => ({
pk: primaryKey({ columns: [example.userId, example.meetingId] }),
userIdIdx: index("userId_idx").on(example.userId),
meetingIdIdx: index("meetingId_idx").on(example.meetingId),
})
);