import { relations } from 'drizzle-orm'; import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; export const users = sqliteTable('users', { uid: text('uid').primaryKey(), email: text('email').notNull(), displayName: text('display_name').notNull(), photoURL: text('photo_url'), }); export const offices = sqliteTable('offices', { id: text('id').primaryKey(), name: text('name').notNull(), location: text('location').notNull(), capacity: integer('capacity').notNull(), description: text('description'), }); export const reservations = sqliteTable('reservations', { id: text('id').primaryKey(), officeId: text('office_id') .notNull() .references(() => offices.id), userId: text('user_id') .notNull() .references(() => users.uid), officeName: text('office_name').notNull(), userEmail: text('user_email').notNull(), date: text('date').notNull(), startTime: text('start_time').notNull(), endTime: text('end_time').notNull(), createdAt: integer('created_at'), }); export const usersRelations = relations(users, ({ many }) => ({ reservations: many(reservations), })); export const officesRelations = relations(offices, ({ many }) => ({ reservations: many(reservations), })); export const reservationsRelations = relations(reservations, ({ one }) => ({ office: one(offices, { fields: [reservations.officeId], references: [offices.id], }), user: one(users, { fields: [reservations.userId], references: [users.uid], }), }));