-- name: CreateBooking :one
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id, user_id, service_id, event_date,  address, notes, created_at, status;

-- name: ListBookingsByUser :many
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
FROM bookings
WHERE user_id = $1
ORDER BY event_date DESC;

-- name: ListBookingsWithServiceByUser :many
SELECT 
    b.id,
    b.user_id,
    b.service_id,
    b.event_date,
    b.address,
    b.notes,
    b.created_at,
    b.status,
    s.name as service_name,
    s.description as service_description,
    s.price_cents as service_price_cents
FROM bookings b
JOIN services s ON b.service_id = s.id
WHERE b.user_id = $1
ORDER BY b.event_date DESC;

-- name: GetBooking :one
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
FROM bookings
WHERE id = $1;
