feat: add SQL migration to fix misclassified long rentals and update docker-compose configurations
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
-- 16-rental-type-weekend-gap-fix.sql
|
||||
-- Fix misclassified long rentals that were stored as 'weekend'.
|
||||
-- Business rule: only true weekend package may remain 'weekend'; long spans are 'individuell'.
|
||||
|
||||
-- Leads: any weekend booking longer than 2 days must be individuell.
|
||||
update public.leads
|
||||
set rental_type = 'individuell'
|
||||
where coalesce(lower(trim(rental_type)), 'weekend') = 'weekend'
|
||||
and coalesce(total_days, 0) > 2;
|
||||
|
||||
-- Sales orders: same correction.
|
||||
update public.sales_orders
|
||||
set rental_type = 'individuell'
|
||||
where coalesce(lower(trim(rental_type)), 'weekend') = 'weekend'
|
||||
and coalesce(total_days, 0) > 2;
|
||||
|
||||
-- If old rows have unknown/legacy values and >2 days, normalize to individuell as well.
|
||||
update public.leads
|
||||
set rental_type = 'individuell'
|
||||
where coalesce(total_days, 0) > 2
|
||||
and coalesce(lower(trim(rental_type)), '') not in ('individuell', 'weekend', 'single_day');
|
||||
|
||||
update public.sales_orders
|
||||
set rental_type = 'individuell'
|
||||
where coalesce(total_days, 0) > 2
|
||||
and coalesce(lower(trim(rental_type)), '') not in ('individuell', 'weekend', 'single_day');
|
||||
|
||||
notify pgrst, 'reload schema';
|
||||
Reference in New Issue
Block a user