Compare commits

...

4 Commits

3 changed files with 36 additions and 3 deletions
+1
View File
@@ -30,6 +30,7 @@ services:
- ./supabase/migrations/13-rental-type-daily-and-email-guard.sql:/sql/13-rental-type-daily-and-email-guard.sql:ro - ./supabase/migrations/13-rental-type-daily-and-email-guard.sql:/sql/13-rental-type-daily-and-email-guard.sql:ro
- ./supabase/migrations/14-email-requested-trigger.sql:/sql/14-email-requested-trigger.sql:ro - ./supabase/migrations/14-email-requested-trigger.sql:/sql/14-email-requested-trigger.sql:ro
- ./supabase/migrations/15-individuell-vat-subtotal-fix.sql:/sql/15-individuell-vat-subtotal-fix.sql:ro - ./supabase/migrations/15-individuell-vat-subtotal-fix.sql:/sql/15-individuell-vat-subtotal-fix.sql:ro
- ./supabase/migrations/16-rental-type-weekend-gap-fix.sql:/sql/16-rental-type-weekend-gap-fix.sql:ro
kong: kong:
volumes: volumes:
+7 -3
View File
@@ -223,6 +223,7 @@ services:
- /mnt/user/appdata/mc-cars/supabase/migrations/13-rental-type-daily-and-email-guard.sql:/sql/13-rental-type-daily-and-email-guard.sql:ro - /mnt/user/appdata/mc-cars/supabase/migrations/13-rental-type-daily-and-email-guard.sql:/sql/13-rental-type-daily-and-email-guard.sql:ro
- /mnt/user/appdata/mc-cars/supabase/migrations/14-email-requested-trigger.sql:/sql/14-email-requested-trigger.sql:ro - /mnt/user/appdata/mc-cars/supabase/migrations/14-email-requested-trigger.sql:/sql/14-email-requested-trigger.sql:ro
- /mnt/user/appdata/mc-cars/supabase/migrations/15-individuell-vat-subtotal-fix.sql:/sql/15-individuell-vat-subtotal-fix.sql:ro - /mnt/user/appdata/mc-cars/supabase/migrations/15-individuell-vat-subtotal-fix.sql:/sql/15-individuell-vat-subtotal-fix.sql:ro
- /mnt/user/appdata/mc-cars/supabase/migrations/16-rental-type-weekend-gap-fix.sql:/sql/16-rental-type-weekend-gap-fix.sql:ro
entrypoint: ["sh","-c"] entrypoint: ["sh","-c"]
command: command:
- | - |
@@ -254,6 +255,7 @@ services:
psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/13-rental-type-daily-and-email-guard.sql psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/13-rental-type-daily-and-email-guard.sql
psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/14-email-requested-trigger.sql psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/14-email-requested-trigger.sql
psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/15-individuell-vat-subtotal-fix.sql psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/15-individuell-vat-subtotal-fix.sql
psql "postgresql://postgres:$$PGPASSWORD@db:5432/postgres" -v ON_ERROR_STOP=1 -f /sql/16-rental-type-weekend-gap-fix.sql
echo "post-init done." echo "post-init done."
restart: "no" restart: "no"
networks: [mccars] networks: [mccars]
@@ -349,10 +351,11 @@ services:
environment: environment:
SUPABASE_URL: ${SUPABASE_PUBLIC_URL} SUPABASE_URL: ${SUPABASE_PUBLIC_URL}
SUPABASE_ANON_KEY: ${ANON_KEY} SUPABASE_ANON_KEY: ${ANON_KEY}
N8N_WEBHOOK_URL: ${N8N_WEBHOOK_URL}
volumes: volumes:
- /mnt/user/appdata/mc-cars/frontend:/usr/share/nginx/html - /mnt/user/appdata/mc-cars/frontend:/usr/share/nginx/html
- /mnt/user/appdata/mc-cars/frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro - /mnt/user/appdata/mc-cars/frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro
entrypoint: ["/bin/sh", "-c", "printf 'window.MCCARS_CONFIG={SUPABASE_URL:\"%s\",SUPABASE_ANON_KEY:\"%s\"};\\n' \"$$SUPABASE_URL\" \"$$SUPABASE_ANON_KEY\" > /usr/share/nginx/html/config.js && exec nginx -g 'daemon off;'"] entrypoint: ["/bin/sh", "-c", "printf 'window.MCCARS_CONFIG={SUPABASE_URL:\"%s\",SUPABASE_ANON_KEY:\"%s\",N8N_WEBHOOK_URL:\"%s\"};\\n' \"$$SUPABASE_URL\" \"$$SUPABASE_ANON_KEY\" \"$$N8N_WEBHOOK_URL\" > /usr/share/nginx/html/config.js && exec nginx -g 'daemon off;'"]
ports: ports:
- "55580:80" - "55580:80"
networks: [mccars] networks: [mccars]
@@ -370,10 +373,11 @@ services:
environment: environment:
SUPABASE_URL: ${SUPABASE_PUBLIC_URL} SUPABASE_URL: ${SUPABASE_PUBLIC_URL}
SUPABASE_ANON_KEY: ${ANON_KEY} SUPABASE_ANON_KEY: ${ANON_KEY}
N8N_WEBHOOK_URL: ${N8N_WEBHOOK_URL}
volumes: volumes:
- /mnt/user/appdata/mc-cars/frontend:/usr/share/nginx/html - /mnt/user/appdata/mc-cars/frontend:/usr/share/nginx/html
- /mnt/user/appdata/mc-cars/frontend/nginx-admin.conf:/etc/nginx/conf.d/default.conf:ro - /mnt/user/appdata/mc-cars/frontend/nginx-admin.conf:/etc/nginx/conf.d/default.conf:ro
entrypoint: ["/bin/sh", "-c", "printf 'window.MCCARS_CONFIG={SUPABASE_URL:\"%s\",SUPABASE_ANON_KEY:\"%s\"};\\n' \"$$SUPABASE_URL\" \"$$SUPABASE_ANON_KEY\" > /usr/share/nginx/html/config.js && exec nginx -g 'daemon off;'"] entrypoint: ["/bin/sh", "-c", "printf 'window.MCCARS_CONFIG={SUPABASE_URL:\"%s\",SUPABASE_ANON_KEY:\"%s\",N8N_WEBHOOK_URL:\"%s\"};\\n' \"$$SUPABASE_URL\" \"$$SUPABASE_ANON_KEY\" \"$$N8N_WEBHOOK_URL\" > /usr/share/nginx/html/config.js && exec nginx -g 'daemon off;'"]
ports: ports:
- "55581:80" - "55581:80"
networks: [mccars] networks: [mccars]
@@ -397,7 +401,7 @@ services:
N8N_HOST: 0.0.0.0 N8N_HOST: 0.0.0.0
N8N_PORT: 5678 N8N_PORT: 5678
N8N_PROTOCOL: http N8N_PROTOCOL: http
WEBHOOK_URL: ${WEBHOOK_DOMAIN:-http://localhost:55590}/ WEBHOOK_URL: http://localhost:55590/
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY} N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "false" N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "false"
N8N_SECURE_COOKIE: "false" N8N_SECURE_COOKIE: "false"
@@ -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';