rework vehicle handling

This commit is contained in:
Matthias Hochmeister
2026-02-28 13:57:41 +01:00
parent 41fc41bee4
commit 1e478479be
12 changed files with 85 additions and 26 deletions

View File

@@ -71,7 +71,7 @@ const UpdateStatusSchema = z.object({
const CreateWartungslogSchema = z.object({
datum: isoDate,
art: z.enum(['Inspektion', 'Reparatur', 'Kraftstoff', 'Reifenwechsel', 'Hauptuntersuchung', 'Reinigung', 'Sonstiges']).optional(),
art: z.enum(['§57a Prüfung', 'Service', 'Sonstiges']).optional(),
beschreibung: z.string().min(1).max(2000),
km_stand: z.number().int().min(0).optional(),
kraftstoff_liter: z.number().min(0).optional(),

View File

@@ -0,0 +1,24 @@
-- Migration 010: Simplify WartungslogArt from 7 types to 3
-- Maps existing data to new categories and updates the CHECK constraint.
--
-- Old types: New type:
-- Inspektion -> Service
-- Reparatur -> Service
-- Reifenwechsel -> Service
-- Reinigung -> Service
-- Hauptuntersuchung -> §57a Prüfung
-- Kraftstoff -> Sonstiges
-- Sonstiges -> Sonstiges (unchanged)
-- Step 1: Migrate existing data to new type values
UPDATE fahrzeug_wartungslog SET art = 'Service' WHERE art IN ('Inspektion', 'Reparatur', 'Reifenwechsel', 'Reinigung');
UPDATE fahrzeug_wartungslog SET art = '§57a Prüfung' WHERE art = 'Hauptuntersuchung';
UPDATE fahrzeug_wartungslog SET art = 'Sonstiges' WHERE art = 'Kraftstoff';
-- Step 2: Drop the old CHECK constraint on art
ALTER TABLE fahrzeug_wartungslog DROP CONSTRAINT IF EXISTS fahrzeug_wartungslog_art_check;
-- Step 3: Add the new CHECK constraint with simplified types
ALTER TABLE fahrzeug_wartungslog
ADD CONSTRAINT fahrzeug_wartungslog_art_check
CHECK (art IS NULL OR art IN ('§57a Prüfung', 'Service', 'Sonstiges'));

View File

@@ -19,12 +19,8 @@ export const FahrzeugStatusLabel: Record<FahrzeugStatus, string> = {
};
export type WartungslogArt =
| 'Inspektion'
| 'Reparatur'
| 'Kraftstoff'
| 'Reifenwechsel'
| 'Hauptuntersuchung'
| 'Reinigung'
| '§57a Prüfung'
| 'Service'
| 'Sonstiges';
// ── Core Entities ─────────────────────────────────────────────────────────────