From b69f5ff1181de56a77f18c5f06163719d6af2264 Mon Sep 17 00:00:00 2001 From: Manus Date: Fri, 24 Apr 2026 06:17:45 -0400 Subject: [PATCH] =?UTF-8?q?Checkpoint:=20feat:=20ic=C3=B4ne=20verte=20si?= =?UTF-8?q?=20solution=20utilis=C3=A9e=20par=20au=20moins=201=20=C3=A9tabl?= =?UTF-8?q?issement=20-=20modification=20de=20SolutionsLogicielles.tsx=20p?= =?UTF-8?q?our=20afficher=20l'ic=C3=B4ne=20Package=20en=20vert=20(text-gre?= =?UTF-8?q?en-600,=20bg-green-500/10)=20si=20nbEtablissements=20>=200,=20e?= =?UTF-8?q?n=20bleu=20sinon.=20Applicable=20aux=20deux=20vues=20:=20accord?= =?UTF-8?q?=C3=A9on=20et=20liste=20=C3=A0=20plat.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/SolutionsLogicielles.tsx | 6 +- export_sandbox_data.mjs | 98 +++++++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 export_sandbox_data.mjs diff --git a/client/src/pages/SolutionsLogicielles.tsx b/client/src/pages/SolutionsLogicielles.tsx index 7c3f81f..a39efe4 100644 --- a/client/src/pages/SolutionsLogicielles.tsx +++ b/client/src/pages/SolutionsLogicielles.tsx @@ -195,8 +195,8 @@ export default function SolutionsLogicielles() { className="flex-1 flex items-center justify-between px-5 py-4 text-left hover:bg-muted/30 transition-colors" >
-
- +
0 ? 'bg-green-500/10' : 'bg-blue-500/10'}`}> + 0 ? 'text-green-600' : 'text-blue-600'} />
{sol.solutionNom}
@@ -312,7 +312,7 @@ export default function SolutionsLogicielles() { <>
- + 0 ? 'text-green-600 flex-shrink-0' : 'text-blue-500 flex-shrink-0'} /> {sol.solutionNom}
diff --git a/export_sandbox_data.mjs b/export_sandbox_data.mjs new file mode 100644 index 0000000..89aa41f --- /dev/null +++ b/export_sandbox_data.mjs @@ -0,0 +1,98 @@ +/** + * Export des données de la base Sandbox SONUM vers un script SQL d'injection. + * Tables exportées : blocs_fonctionnels, editeurs, etablissements, solutions, + * logiciels_etablissements, consultations, demandes_contact, user_etablissements + * Tables exclues : users, local_credentials, __drizzle_migrations + */ +import mysql from 'mysql2/promise'; +import fs from 'fs'; + +const TABLES_TO_EXPORT = [ + 'blocs_fonctionnels', + 'editeurs', + 'etablissements', + 'solutions', + 'logiciels_etablissements', + 'consultations', + 'demandes_contact', + 'user_etablissements', +]; + +const conn = await mysql.createConnection(process.env.DATABASE_URL); + +let sql = `-- Export données SONUM Sandbox → VPS +-- Généré le ${new Date().toISOString()} +-- Tables : ${TABLES_TO_EXPORT.join(', ')} +-- ATTENTION : exclut users, local_credentials, __drizzle_migrations + +SET FOREIGN_KEY_CHECKS = 0; +SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'; + +`; + +for (const table of TABLES_TO_EXPORT) { + console.log(`Exporting table: ${table}...`); + + // Récupérer la structure de la table + const [[createResult]] = await conn.execute(`SHOW CREATE TABLE \`${table}\``); + const createSQL = createResult['Create Table']; + + // Récupérer les données + const [rows] = await conn.execute(`SELECT * FROM \`${table}\``); + + sql += `-- ─────────────────────────────────────────────────────────────────\n`; + sql += `-- Table: ${table} (${rows.length} lignes)\n`; + sql += `-- ─────────────────────────────────────────────────────────────────\n`; + sql += `TRUNCATE TABLE \`${table}\`;\n\n`; + + if (rows.length === 0) { + sql += `-- (aucune donnée)\n\n`; + continue; + } + + // Générer les INSERT par lots de 50 + const columns = Object.keys(rows[0]); + const colList = columns.map(c => `\`${c}\``).join(', '); + + const BATCH_SIZE = 50; + for (let i = 0; i < rows.length; i += BATCH_SIZE) { + const batch = rows.slice(i, i + BATCH_SIZE); + const values = batch.map(row => { + const vals = columns.map(col => { + const v = row[col]; + if (v === null || v === undefined) return 'NULL'; + if (typeof v === 'number' || typeof v === 'bigint') return String(v); + if (typeof v === 'boolean') return v ? '1' : '0'; + if (v instanceof Date) return `'${v.toISOString().slice(0, 19).replace('T', ' ')}'`; + // Escape string + const escaped = String(v) + .replace(/\\/g, '\\\\') + .replace(/'/g, "\\'") + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\0/g, '\\0'); + return `'${escaped}'`; + }); + return `(${vals.join(', ')})`; + }); + sql += `INSERT INTO \`${table}\` (${colList}) VALUES\n${values.join(',\n')};\n`; + } + sql += `\n`; +} + +sql += `SET FOREIGN_KEY_CHECKS = 1;\n`; +sql += `-- Fin de l'export\n`; + +await conn.end(); + +const outputPath = '/home/ubuntu/sonum_data_export.sql'; +fs.writeFileSync(outputPath, sql, 'utf8'); + +const stats = fs.statSync(outputPath); +console.log(`\nExport terminé : ${outputPath}`); +console.log(`Taille : ${(stats.size / 1024).toFixed(1)} KB`); +console.log(`\nRésumé par table :`); +for (const table of TABLES_TO_EXPORT) { + const matches = sql.match(new RegExp(`-- Table: ${table} \\((\\d+) lignes\\)`)); + if (matches) console.log(` ${table}: ${matches[1]} lignes`); +}