rework vehicle handling
This commit is contained in:
@@ -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'));
|
||||
Reference in New Issue
Block a user