bmc_hub/migrations/1057_sag_v5_time_billing_source.sql
Christian 4871dd2d9e Add comprehensive test coverage for various modules
- Introduced tests for mail templates including ranking, rendering, and attachment handling.
- Added tests for time billing selection and approval processes, ensuring proper validation and state management.
- Implemented tests for case types in JavaScript, focusing on loading and editing functionality.
- Created tests for contact mail AI integration, ensuring proper parsing and error handling.
- Developed tests for dark theme CSS contrast and loading order.
- Added tests for invoice fee service, covering various scenarios including exemptions and invalid inputs.
- Implemented vendor resource tests, ensuring proper file handling and query validation.
2026-10-08 08:58:02 +02:00

17 lines
851 B
SQL

-- Additive: distinguish explicit V5 billing choices without changing legacy approval defaults.
-- Expand the existing source check; preserve its expression and all historical rows.
DO $$
DECLARE existing_expression TEXT;
BEGIN
SELECT pg_get_expr(conbin, conrelid) INTO existing_expression
FROM pg_constraint
WHERE conrelid = 'tmodule_times'::regclass AND conname = 'tmodule_times_kilde_check';
IF existing_expression IS NULL THEN
existing_expression := 'kilde IN (''auto'', ''manuel'', ''api'')';
END IF;
IF POSITION('sag_v5' IN existing_expression) = 0 THEN
ALTER TABLE tmodule_times DROP CONSTRAINT IF EXISTS tmodule_times_kilde_check;
EXECUTE FORMAT('ALTER TABLE tmodule_times ADD CONSTRAINT tmodule_times_kilde_check CHECK ((%s) OR kilde = %L)', existing_expression, 'sag_v5');
END IF;
END $$;