Supprime les contraintes en doublons (vieilles contraintes non nommes)
This commit is contained in:
parent
95d4656edb
commit
7c29b7f9cc
@ -131,6 +131,34 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
}
|
||||
|
||||
|
||||
// Suppression vieilles contraintes sans noms et en doubles
|
||||
// Les contraintes indesirables ont un nom qui commence par 0_ ou se termine par ibfk_999
|
||||
$listtables=array('llx_product_fournisseur_price','llx_fichinter','llx_facture_fourn','llx_propal','llx_socpeople','llx_telephonie_adsl_fournisseur','llx_telephonie_client_stats','llx_telephonie_contact_facture','llx_telephonie_societe_ligne','llx_telephonie_tarif_client');
|
||||
foreach ($listtables as $val)
|
||||
{
|
||||
$sql = "SHOW CREATE TABLE ".$val;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) dolibarr_print_error($db);
|
||||
{
|
||||
$values=$db->fetch_array($resql);
|
||||
$i=0;
|
||||
$createsql=$values[1];
|
||||
while (eregi('CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`',$createsql,$reg) && $i < 100)
|
||||
{
|
||||
$sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
|
||||
$resqldrop = $db->query($sqldrop);
|
||||
if ($resqldrop)
|
||||
{
|
||||
print '<tr><td colspan="2">'.$sqldrop.";</td></tr>\n";
|
||||
}
|
||||
$createsql=eregi_replace('CONSTRAINT `'.$reg[1].'`','XXX',$createsql);
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user