-- ============================================================================ -- Migration 031: Tilføj manglende kolonner til tmodule_times og tmodule_order_lines -- ============================================================================ -- Retter bug hvor kolonner blev referenced i koden men aldrig tilføjet til DB -- ============================================================================ -- Tilføj manglende kolonner til tmodule_times ALTER TABLE tmodule_times ADD COLUMN IF NOT EXISTS is_travel BOOLEAN DEFAULT false; 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 when the legacy tracking table exists DO $$ BEGIN IF EXISTS ( SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'migration_log' ) THEN INSERT INTO migration_log (migration_name, applied_at) VALUES ('031_add_is_travel_column', CURRENT_TIMESTAMP) ON CONFLICT DO NOTHING; END IF; END $$;