Auto-commit for deploy to staging - 2026-06-04 15:04:00
This commit is contained in:
+18
-6
@@ -200,16 +200,28 @@ foreach ($families as $f) {
|
|||||||
// ==========================================
|
// ==========================================
|
||||||
echo "<li><strong>Table pf_alloc_categories (Récupération des données) :</strong> ";
|
echo "<li><strong>Table pf_alloc_categories (Récupération des données) :</strong> ";
|
||||||
try {
|
try {
|
||||||
$updated1 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = target, target = '0' WHERE target LIKE 'vers %'");
|
// Vérifier si la colonne target est encore au format texte (VARCHAR)
|
||||||
|
$stmtCol = $fam_pdo->query("SHOW COLUMNS FROM pf_alloc_categories LIKE 'target'");
|
||||||
|
$colInfo = $stmtCol->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$updated2 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = 'SYSTEM', target = '0' WHERE target = 'SYSTEM'");
|
if ($colInfo && strpos(strtolower($colInfo['Type']), 'varchar') !== false) {
|
||||||
|
// 1. Déplacer les textes "vers..."
|
||||||
|
$updated1 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = target, target = '0' WHERE target LIKE 'vers %'");
|
||||||
|
|
||||||
$fam_pdo->exec("UPDATE pf_alloc_categories SET target = '0' WHERE target NOT REGEXP '^[0-9]+(\.[0-9]+)?$'");
|
// 2. Gérer le mot 'SYSTEM'
|
||||||
|
$updated2 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = 'SYSTEM', target = '0' WHERE target = 'SYSTEM'");
|
||||||
|
|
||||||
echo "<span style='color:green'>" . ($updated1 + $updated2) . " destinations récupérées et déplacées.</span></li>";
|
// 3. Sécurité absolue avant conversion
|
||||||
|
$fam_pdo->exec("UPDATE pf_alloc_categories SET target = '0' WHERE target NOT REGEXP '^[0-9]+(\\\\.[0-9]+)?$'");
|
||||||
|
|
||||||
$fam_pdo->exec("ALTER TABLE pf_alloc_categories MODIFY target DECIMAL(10,2) DEFAULT 0.00");
|
echo "<span style='color:green'>" . ($updated1 + $updated2) . " destinations récupérées et déplacées.</span><br>";
|
||||||
echo "<li><span style='color:green'>Colonne 'target' re-sécurisée en format monétaire DECIMAL(10,2).</span></li>";
|
|
||||||
|
// 4. Remettre la colonne en format numérique
|
||||||
|
$fam_pdo->exec("ALTER TABLE pf_alloc_categories MODIFY target DECIMAL(10,2) DEFAULT 0.00");
|
||||||
|
echo "<span style='color:green'>Colonne 'target' re-sécurisée en format monétaire DECIMAL(10,2).</span></li>";
|
||||||
|
} else {
|
||||||
|
echo "<span style='color:gray'>La colonne 'target' est déjà au format DECIMAL, transfert ignoré.</span></li>";
|
||||||
|
}
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
echo "<span style='color:red'>Erreur : " . $e->getMessage() . "</span></li>";
|
echo "<span style='color:red'>Erreur : " . $e->getMessage() . "</span></li>";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user