-- A appliquer via phpMyAdmin apres 2026-07-05_categories_apparence.sql.
-- Panneau admin : table des enseignes + icones de categories au format
-- bibliotheque d'icones (Font Awesome "fa-solid fa-xxx" / Tabler "ti ti-xxx").

ALTER TABLE categories
    MODIFY icon VARCHAR(60) NULL COMMENT 'classes CSS de l''icone (Font Awesome ou Tabler), ex. "fa-solid fa-house"';

-- Conversion des anciens identifiants d'icones (jeu SVG interne) si le seed
-- categories_defaut.sql avait ete importe avant cette migration.
UPDATE categories SET icon = CASE icon
    WHEN 'home' THEN 'fa-solid fa-house'
    WHEN 'cart' THEN 'fa-solid fa-cart-shopping'
    WHEN 'bus' THEN 'fa-solid fa-bus'
    WHEN 'utensils' THEN 'fa-solid fa-utensils'
    WHEN 'gamepad' THEN 'fa-solid fa-gamepad'
    WHEN 'repeat' THEN 'fa-solid fa-repeat'
    WHEN 'heart' THEN 'fa-solid fa-heart-pulse'
    WHEN 'receipt' THEN 'fa-solid fa-receipt'
    WHEN 'dots' THEN 'fa-solid fa-ellipsis'
    ELSE icon
END
WHERE icon IS NOT NULL;

-- Enseignes (commerces/services), creees par les admins. Les logos vivent
-- dans storage/merchants/. Les futures operations y feront reference.
CREATE TABLE IF NOT EXISTS merchants (
    id              INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name            VARCHAR(100) NOT NULL,
    logo_filename   VARCHAR(100) NULL,
    created_at      DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at      DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

    UNIQUE KEY uq_merchants_name (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
