-- ============================================================================================
-- PRODUCTION MIGRATION — Contact LinkedIn URL
-- ============================================================================================
-- Adds an optional LinkedIn profile URL to dim_contacts.
-- Idempotent — safe to re-run.
-- Deploy: mysql -u root -p db_abos_v0.1 < db/add_contact_linkedin_url.sql
-- ============================================================================================

USE db_abos_v0.1;

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