-- ============================================================================================
-- PRODUCTION MIGRATION — Project Git Repository URL
-- ============================================================================================
-- Adds an optional Git repository URL to dim_projects (surfaced in the UI for Technical-type
-- projects, but not enforced/scoped by type at the DB or API level).
-- Idempotent — safe to re-run.
-- Deploy: mysql -u <user> -p `stacie_Aggie_v1.0` < db/add_project_git_repo_url.sql
-- ============================================================================================

USE `stacie_Aggie_v1.0`;

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