Auto-commit for deploy to staging - 2026-06-04 15:04:00
This commit is contained in:
+21
-9
@@ -200,16 +200,28 @@ foreach ($families as $f) {
|
||||
// ==========================================
|
||||
echo "<li><strong>Table pf_alloc_categories (Récupération des données) :</strong> ";
|
||||
try {
|
||||
$updated1 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = target, target = '0' WHERE target LIKE 'vers %'");
|
||||
|
||||
$updated2 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = 'SYSTEM', target = '0' WHERE target = 'SYSTEM'");
|
||||
|
||||
$fam_pdo->exec("UPDATE pf_alloc_categories SET target = '0' WHERE target NOT REGEXP '^[0-9]+(\.[0-9]+)?$'");
|
||||
// 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);
|
||||
|
||||
echo "<span style='color:green'>" . ($updated1 + $updated2) . " destinations récupérées et déplacées.</span></li>";
|
||||
|
||||
$fam_pdo->exec("ALTER TABLE pf_alloc_categories MODIFY target DECIMAL(10,2) DEFAULT 0.00");
|
||||
echo "<li><span style='color:green'>Colonne 'target' re-sécurisée en format monétaire DECIMAL(10,2).</span></li>";
|
||||
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 %'");
|
||||
|
||||
// 2. Gérer le mot 'SYSTEM'
|
||||
$updated2 = $fam_pdo->exec("UPDATE pf_alloc_categories SET transfer_dest = 'SYSTEM', target = '0' WHERE target = 'SYSTEM'");
|
||||
|
||||
// 3. Sécurité absolue avant conversion
|
||||
$fam_pdo->exec("UPDATE pf_alloc_categories SET target = '0' WHERE target NOT REGEXP '^[0-9]+(\\\\.[0-9]+)?$'");
|
||||
|
||||
echo "<span style='color:green'>" . ($updated1 + $updated2) . " destinations récupérées et déplacées.</span><br>";
|
||||
|
||||
// 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) {
|
||||
echo "<span style='color:red'>Erreur : " . $e->getMessage() . "</span></li>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user