Fix: Tilføj manglende kolonner til tmodule_order_lines

CRITICAL BUG FIX:
- case_contact, time_date, is_travel manglede i tmodule_order_lines tabel
- Forårsagede SQL fejl ved order creation INSERT
- Opdateret migration 031 til at tilføje alle manglende kolonner
- Applied direkte på production DB

ERROR: column 'case_contact' does not exist
  → INSERT INTO tmodule_order_lines ... case_contact, time_date, is_travel
This commit is contained in:
Christian 2025-12-23 00:33:28 +01:00
parent 0fdf4549d6
commit 776f7a52ad

View File

@ -1,20 +1,29 @@
-- ============================================================================
-- Migration 031: Tilføj is_travel kolonne til tmodule_times
-- Migration 031: Tilføj manglende kolonner til tmodule_times og tmodule_order_lines
-- ============================================================================
-- Retter bug hvor is_travel blev referenced i koden men aldrig tilføjet til DB
-- Retter bug hvor kolonner blev referenced i koden men aldrig tilføjet til DB
-- ============================================================================
-- Tilføj is_travel kolonne
-- Tilføj manglende kolonner til tmodule_times
ALTER TABLE tmodule_times
ADD COLUMN IF NOT EXISTS is_travel BOOLEAN DEFAULT false;
-- Tilføj hourly_rate kolonne (bruges også i approve endpoint)
ALTER TABLE tmodule_times
ADD COLUMN IF NOT EXISTS hourly_rate DECIMAL(10,2);
-- Index for hurtig filtrering af rejsetid
CREATE INDEX IF NOT EXISTS idx_tmodule_times_is_travel ON tmodule_times(is_travel);
-- Tilføj manglende kolonner til tmodule_order_lines (bruges ved order creation)
ALTER TABLE tmodule_order_lines
ADD COLUMN IF NOT EXISTS case_contact VARCHAR(255);
ALTER TABLE tmodule_order_lines
ADD COLUMN IF NOT EXISTS time_date DATE;
ALTER TABLE tmodule_order_lines
ADD COLUMN IF NOT EXISTS is_travel BOOLEAN DEFAULT false;
-- Log migration
INSERT INTO migration_log (migration_name, applied_at)
VALUES ('031_add_is_travel_column', CURRENT_TIMESTAMP)