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:
@@ -65,6 +65,9 @@ begin
|
||||
|
||||
-- Let authenticator impersonate app roles.
|
||||
execute 'grant anon, authenticated, service_role to authenticator';
|
||||
|
||||
-- Let storage_admin impersonate app roles (needed for RLS on storage.objects).
|
||||
execute 'grant anon, authenticated, service_role to supabase_storage_admin';
|
||||
end
|
||||
$roles$;
|
||||
|
||||
@@ -165,34 +168,9 @@ insert into public.vehicles
|
||||
(brand, model, power_hp, top_speed_kmh, acceleration, seats,
|
||||
daily_price_eur, location, description_de, description_en, photo_url, sort_order)
|
||||
values
|
||||
('Porsche','911 GT3', 510, 318, '3.4s', 2, 890, 'Steiermark (TBD)',
|
||||
'Puristischer Hochdrehzahl-Saugmotor und kompromissloser Motorsport-Charakter.',
|
||||
'Pure high-revving naturally aspirated engine with uncompromising motorsport character.',
|
||||
'https://images.unsplash.com/photo-1611821064430-0d40291d0f0b?auto=format&fit=crop&w=1400&q=80',
|
||||
10),
|
||||
('Lamborghini','Huracan EVO', 640, 325, '2.9s', 2, 990, 'Steiermark (TBD)',
|
||||
'V10 mit 640 PS, scharfes Design und kompromisslose Performance auf Strasse und Rennstrecke.',
|
||||
'V10 with 640 hp, sharp design and uncompromising performance on road and track.',
|
||||
'https://images.unsplash.com/photo-1544636331-e26879cd4d9b?auto=format&fit=crop&w=1400&q=80',
|
||||
20),
|
||||
('Audi','RS6 Performance', 630, 305, '3.4s', 5, 540, 'Steiermark (TBD)',
|
||||
'Alltagstauglicher Kombi mit brutaler V8-Biturbo-Power und Allradantrieb.',
|
||||
'Everyday-ready estate with brutal twin-turbo V8 power and quattro AWD.',
|
||||
'https://images.unsplash.com/photo-1606664515524-ed2f786a0bd6?auto=format&fit=crop&w=1400&q=80',
|
||||
30),
|
||||
('BMW','M4 Competition', 530, 290, '3.5s', 4, 430, 'Steiermark (TBD)',
|
||||
'Reihensechszylinder-Biturbo mit praeziser Lenkung und sportlichem Fahrwerk.',
|
||||
'Twin-turbo inline-six with precise steering and sporty chassis.',
|
||||
'https://images.unsplash.com/photo-1555215695-3004980ad54e?auto=format&fit=crop&w=1400&q=80',
|
||||
40),
|
||||
('Nissan','GT-R R35', 570, 315, '2.8s', 4, 510, 'Steiermark (TBD)',
|
||||
'Ikonischer Allrad-Supersportler mit Twin-Turbo V6 und brutalem Antritt.',
|
||||
'Iconic AWD supercar with twin-turbo V6 and ferocious launch.',
|
||||
'https://images.unsplash.com/photo-1626668893632-6f3a4466d22f?auto=format&fit=crop&w=1400&q=80',
|
||||
50),
|
||||
('Mercedes-AMG','G63', 585, 220, '4.5s', 5, 620, 'Steiermark (TBD)',
|
||||
'Legendaere G-Klasse mit V8-Biturbo-Performance und unverkennbarem Design.',
|
||||
'Legendary G-Class with V8 biturbo performance and unmistakable design.',
|
||||
'https://images.unsplash.com/photo-1606611013016-969c19ba27bb?auto=format&fit=crop&w=1400&q=80',
|
||||
60)
|
||||
('Ferrari','296 GTB', 830, 330, '2.9s', 2, 850, 'Steiermark (TBD)',
|
||||
'V6-Hybrid mit 830 PS, atemberaubendes Design und kompromisslose Performance auf Strasse und Rennstrecke.',
|
||||
'V6 hybrid with 830 hp, breathtaking design and uncompromising performance on road and track.',
|
||||
'/images/ferrari-main-car.png',
|
||||
10)
|
||||
on conflict do nothing;
|
||||
|
||||
@@ -16,6 +16,12 @@ update public.vehicles
|
||||
max_daily_km = 150
|
||||
where weekend_price_eur = 0;
|
||||
|
||||
-- Ferrari gets specific pricing
|
||||
update public.vehicles
|
||||
set weekend_price_eur = 1100,
|
||||
max_daily_km = 200
|
||||
where brand = 'Ferrari' and model = '296 GTB';
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
-- 2. Lead attachments: documents uploaded during booking flow
|
||||
-- -----------------------------------------------------------------------------
|
||||
|
||||
@@ -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';
|
||||
@@ -60,9 +60,14 @@ on conflict (id) do update
|
||||
file_size_limit = excluded.file_size_limit,
|
||||
allowed_mime_types = excluded.allowed_mime_types;
|
||||
|
||||
-- Let storage_admin assume app roles for RLS evaluation (idempotent).
|
||||
grant anon, authenticated, service_role to supabase_storage_admin;
|
||||
|
||||
grant select on storage.buckets to anon, authenticated;
|
||||
grant all on storage.buckets to service_role;
|
||||
grant select on storage.objects to anon;
|
||||
grant select, insert, update, delete on storage.objects to authenticated;
|
||||
grant all on storage.objects to service_role;
|
||||
|
||||
drop policy if exists "vehicle_photos_public_read" on storage.objects;
|
||||
drop policy if exists "vehicle_photos_admin_insert" on storage.objects;
|
||||
|
||||
Reference in New Issue
Block a user