bmc_hub/migrations/099_worklog_rounded_hours.sql

14 lines
581 B
MySQL
Raw Normal View History

-- Migration: Add rounded_hours to tticket_worklog for prepaid card billing
-- Add rounded_hours column (actual hours deducted from prepaid card after rounding)
ALTER TABLE tticket_worklog
ADD COLUMN IF NOT EXISTS rounded_hours DECIMAL(5,2);
COMMENT ON COLUMN tticket_worklog.rounded_hours IS 'Rounded hours (actual amount deducted from prepaid card). NULL if not prepaid or no rounding applied.';
-- Backfill: Set rounded_hours = hours for existing prepaid entries
UPDATE tticket_worklog
SET rounded_hours = hours
WHERE prepaid_card_id IS NOT NULL
AND rounded_hours IS NULL;