-- =====================================================
-- MIGRATION: Suppression des colonnes icon_path/background_path
-- =====================================================
-- Ce script supprime les colonnes de chemins d'assets de la base de donnees.
-- Les chemins sont maintenant geres uniquement cote client.
--
-- Tables affectees:
--   - weapons: suppression de icon_path
--   - armors: suppression de icon_path
--   - quests: suppression de background_path
--   - relique_definitions: suppression de icon_path


-- =====================================================
-- WEAPONS: Supprimer icon_path
-- =====================================================
-- Verifier si la colonne existe avant de la supprimer
SET @column_exists = (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'weapons'
    AND COLUMN_NAME = 'icon_path'
);

SET @sql = IF(@column_exists > 0,
    'ALTER TABLE weapons DROP COLUMN icon_path',
    'SELECT "Column icon_path does not exist in weapons" AS message'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

-- =====================================================
-- ARMORS: Supprimer icon_path
-- =====================================================
SET @column_exists = (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'armors'
    AND COLUMN_NAME = 'icon_path'
);

SET @sql = IF(@column_exists > 0,
    'ALTER TABLE armors DROP COLUMN icon_path',
    'SELECT "Column icon_path does not exist in armors" AS message'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

-- =====================================================
-- QUESTS: Supprimer background_path
-- =====================================================
SET @column_exists = (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'quests'
    AND COLUMN_NAME = 'background_path'
);

SET @sql = IF(@column_exists > 0,
    'ALTER TABLE quests DROP COLUMN background_path',
    'SELECT "Column background_path does not exist in quests" AS message'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

-- =====================================================
-- RELIQUE_DEFINITIONS: Supprimer icon_path
-- =====================================================
SET @column_exists = (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'relique_definitions'
    AND COLUMN_NAME = 'icon_path'
);

SET @sql = IF(@column_exists > 0,
    'ALTER TABLE relique_definitions DROP COLUMN icon_path',
    'SELECT "Column icon_path does not exist in relique_definitions" AS message'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

-- =====================================================
-- Verification finale
-- =====================================================
SELECT 'Migration terminee - colonnes icon_path/background_path supprimees' AS status;
