feat: add deposit and weekend km allowance to vehicles, update migrations and booking flow

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
LagoESP
2026-04-29 16:00:06 +02:00
parent d960e37aa8
commit e85b319c93
10 changed files with 83 additions and 39 deletions
@@ -0,0 +1,27 @@
-- =============================================================================
-- MC Cars - Add per-vehicle kaution (deposit) and max_km_weekend columns.
-- Idempotent.
-- =============================================================================
-- -----------------------------------------------------------------------------
-- 1. kaution_eur: deposit per vehicle, NOT NULL, default 5000, must be > 0
-- -----------------------------------------------------------------------------
alter table public.vehicles add column if not exists kaution_eur integer not null default 5000;
do $$
begin
if not exists (
select 1 from information_schema.check_constraints
where constraint_name = 'vehicles_kaution_positive'
) then
alter table public.vehicles add constraint vehicles_kaution_positive check (kaution_eur > 0);
end if;
end $$;
-- -----------------------------------------------------------------------------
-- 2. max_km_weekend: optional per-weekend-day km allowance (NULL = use max_daily_km)
-- -----------------------------------------------------------------------------
alter table public.vehicles add column if not exists max_km_weekend integer default null;
-- Signal PostgREST to reload its schema cache
notify pgrst, 'reload schema';