🎉 initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { integer, pgTable, serial, text, timestamp, unique } from 'drizzle-orm/pg-core'
|
||||
|
||||
export const restaurantTables = pgTable('restaurant_tables', {
|
||||
id: serial('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
seats: integer('seats').notNull(),
|
||||
})
|
||||
|
||||
export const reservations = pgTable(
|
||||
'reservations',
|
||||
{
|
||||
id: serial('id').primaryKey(),
|
||||
tableId: integer('table_id')
|
||||
.notNull()
|
||||
.references(() => restaurantTables.id, { onDelete: 'cascade' }),
|
||||
customerName: text('customer_name').notNull(),
|
||||
customerEmail: text('customer_email').notNull(),
|
||||
partySize: integer('party_size').notNull(),
|
||||
reservationTime: timestamp('reservation_time', { withTimezone: true }).notNull(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [unique().on(table.tableId, table.reservationTime)],
|
||||
)
|
||||
|
||||
export type RestaurantTable = typeof restaurantTables.$inferSelect
|
||||
export type Reservation = typeof reservations.$inferSelect
|
||||
export type NewReservation = typeof reservations.$inferInsert
|
||||
Reference in New Issue
Block a user