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:
@@ -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';
|
||||
Reference in New Issue
Block a user