-- ============================================================================================
-- PRODUCTION MIGRATION — Workitem Story Points
-- ============================================================================================
-- Adds an optional Story Points estimate to fact_project_tasks, used by the Estimation tab
-- for Feature/PBI rollups (Technical projects). Idempotent — safe to re-run.
-- Deploy: mysql -u <user> -p `stacie_Aggie_v1.0` < db/add_task_story_points.sql
-- ============================================================================================

USE `stacie_Aggie_v1.0`;

SET @col_exists = (
    SELECT COUNT(*) FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'fact_project_tasks' AND COLUMN_NAME = 'story_points'
);
SET @sql = IF(@col_exists = 0, 'ALTER TABLE fact_project_tasks ADD COLUMN story_points INT NULL', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
