bmc_hub/migrations/031_add_is_travel_column.sql
Christian 92b888b78f Add migrations for seeding tags and enhancing todo steps
- Created migration 146 to seed case type tags with various categories and keywords.
- Created migration 147 to seed brand and type tags, including a comprehensive list of brands and case types.
- Added migration 148 to introduce a new column `is_next` in `sag_todo_steps` for persistent next-task selection.
- Implemented a new script `run_migrations.py` to facilitate running SQL migrations against the PostgreSQL database with options for dry runs and error handling.
2026-03-20 00:24:58 +01:00

41 lines
1.5 KiB
SQL

-- ============================================================================
-- 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 $$;