/**
 * seed-app-logo.js — Enregistre app-logo.svg dans la bibliothèque d'icônes.
 * Usage (depuis le dossier backend/) : node scripts/seed-app-logo.js
 */

import 'dotenv/config';
import db from '../src/db/index.js';

const existing = db.prepare("SELECT id FROM app_icons WHERE name = 'logo-app'").get();

if (existing) {
  db.prepare(`
    INSERT INTO app_icons_history (icon_id, filename, replaced_at)
    SELECT id, filename, datetime('now') FROM app_icons WHERE name = 'logo-app'
  `).run();
  db.prepare(`
    UPDATE app_icons
    SET filename = 'app-logo.svg', description = 'Logo principal de la plateforme', updated_at = datetime('now')
    WHERE name = 'logo-app'
  `).run();
  console.log('✓ Icône logo-app mise à jour → app-logo.svg');
} else {
  db.prepare(`
    INSERT INTO app_icons (name, filename, description)
    VALUES ('logo-app', 'app-logo.svg', 'Logo principal de la plateforme')
  `).run();
  console.log('✓ Icône logo-app créée → app-logo.svg');
}
