-- ============================================================================================
-- PRODUCTION MIGRATION — Task Start Date
-- ============================================================================================
-- Adds an optional start date to fact_project_tasks, alongside the existing due_date.
-- Idempotent — safe to re-run.
-- Deploy: mysql -u root -p db_abos_v0.1 < db/add_task_start_date.sql
-- ============================================================================================

USE db_abos_v0.1;

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