feat(workshop): vehicles must be assigned to a customer
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

- Added customer_id column to fleet_vehicles with FK to customers.

- Enforced customer_id on create_vehicle endpoints (workshop and fleet).

- New vehicle modal now requires a selected customer and stores customer_id.

- Migration v4.13 applied to all tenants.
This commit is contained in:
2026-06-30 19:53:00 +00:00
parent 1af66cb302
commit 66b8fe3d69
5 changed files with 76 additions and 16 deletions

View File

@@ -0,0 +1,20 @@
-- v4.13_fleet_vehicle_customer.sql
-- Link fleet vehicles to a customer.
ALTER TABLE fleet_vehicles
ADD COLUMN IF NOT EXISTS customer_id INTEGER;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'fleet_vehicles_customer_id_fkey'
) THEN
ALTER TABLE fleet_vehicles
ADD CONSTRAINT fleet_vehicles_customer_id_fkey
FOREIGN KEY (customer_id) REFERENCES customers(id);
END IF;
END $$;
CREATE INDEX IF NOT EXISTS idx_fleet_vehicles_customer_id
ON fleet_vehicles (customer_id);