feat: Enhance reservation functionality

This commit is contained in:
2026-04-22 10:23:22 -04:00
parent 7f1e82acc2
commit 534d66c774
25 changed files with 1236 additions and 91 deletions

View File

@@ -0,0 +1,25 @@
-- Expose user_id and member_name in reservation_slots.
-- JOIN with members is safe here because security_invoker=false runs as view owner,
-- bypassing RLS — so any authenticated user can see names without a separate members query.
-- Must drop+recreate because CREATE OR REPLACE VIEW cannot insert a column mid-list.
drop view if exists public.reservation_slots;
create view public.reservation_slots
with (security_invoker = false)
as
select
r.id,
r.boat_id,
r.user_id,
r.start_time,
r.end_time,
r.status,
coalesce(
nullif(trim(m.first_name || ' ' || m.last_name), ''),
m.email
) as member_name
from public.reservations r
left join public.members m on m.user_id = r.user_id
where r.status <> 'cancelled';
grant select on public.reservation_slots to authenticated;