| 1 | import { |
| 2 | pgTable, |
| 3 | uuid, |
| 4 | varchar, |
| 5 | text, |
| 6 | timestamp, |
| 7 | integer, |
| 8 | pgEnum, |
| 9 | } from 'drizzle-orm/pg-core'; |
| 10 | import { users } from './users'; |
| 11 | |
| 12 | export const eventStatusEnum = pgEnum('event_status', [ |
| 13 | 'DRAFT', |
| 14 | 'PUBLISHED', |
| 15 | 'CANCELLED', |
| 16 | ]); |
| 17 | |
| 18 | export const events = pgTable('events', { |
| 19 | id: uuid('id').defaultRandom().primaryKey(), |
| 20 | title: varchar('title', { length: 255 }).notNull(), |
| 21 | description: text('description'), |
| 22 | date: timestamp('date').notNull(), |
| 23 | location: varchar('location', { length: 255 }).notNull(), |
| 24 | capacity: integer('capacity').notNull(), |
| 25 | price: integer('price').default(0).notNull(), |
| 26 | status: eventStatusEnum('status').default('DRAFT').notNull(), |
| 27 | organizerId: uuid('organize_id') |
| 28 | .references(() => users.id) |
| 29 | .notNull(), |
| 30 | createdAt: timestamp('created_at').defaultNow().notNull(), |
| 31 | updatedAt: timestamp('updated_at').defaultNow().notNull(), |
| 32 | }); |
| 33 | |
| 34 | export type Event = typeof events.$inferSelect; |
| 35 | export type NewEvent = typeof events.$inferInsert; |