refactor(bookings): simplify capacity tracking to use seats
Replace 'pax' booking mode with 'seat' Consolidate inventory summary to track only seat counts Update database schema and UI for seat-centric capacity
This commit is contained in:
@@ -69,7 +69,7 @@ async function initializeDatabase() {
|
||||
receipt_token text not null unique,
|
||||
customer_name text not null,
|
||||
customer_phone text not null,
|
||||
booking_mode text not null check (booking_mode in ('table', 'pax')),
|
||||
booking_mode text not null check (booking_mode in ('table', 'seat')),
|
||||
quantity integer not null check (quantity >= 1),
|
||||
seat_count integer not null check (seat_count >= 1),
|
||||
ticket_type text not null check (ticket_type in ('vip', 'supporter')),
|
||||
@@ -124,6 +124,11 @@ async function initializeDatabase() {
|
||||
)
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table booking_settings
|
||||
add column if not exists total_seats integer
|
||||
`
|
||||
|
||||
await sql`
|
||||
insert into booking_settings (id)
|
||||
values ('default')
|
||||
@@ -146,6 +151,45 @@ async function initializeDatabase() {
|
||||
`
|
||||
}
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
drop constraint if exists bookings_booking_mode_check
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add constraint bookings_booking_mode_check
|
||||
check (booking_mode in ('table', 'pax', 'seat'))
|
||||
`
|
||||
|
||||
await sql`
|
||||
update bookings
|
||||
set
|
||||
booking_mode = 'seat',
|
||||
updated_at = now()
|
||||
where booking_mode = 'pax'
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
drop constraint if exists bookings_booking_mode_check
|
||||
`
|
||||
|
||||
await sql`
|
||||
alter table bookings
|
||||
add constraint bookings_booking_mode_check
|
||||
check (booking_mode in ('table', 'seat'))
|
||||
`
|
||||
|
||||
await sql`
|
||||
update booking_settings
|
||||
set
|
||||
total_seats = total_tables * 10,
|
||||
updated_at = now()
|
||||
where total_seats is null
|
||||
and total_tables is not null
|
||||
`
|
||||
|
||||
const existingBookings = await sql<{ id: string, seat_count: number | string }[]>`
|
||||
select
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user