there's some changes, to accomodate 5194. More testing is needed on all versions of mysql

This commit is contained in:
toyomoyo 2006-04-20 06:57:26 +00:00
parent 4c85af7b01
commit 8de65352a4

View file

@ -347,6 +347,56 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
echo "<br>---><b>method ".$method.'</b>'; echo "<br>---><b>method ".$method.'</b>';
} }
if ($CFG->dbtype == 'mysql') {
if ($dropindex){ //drop index if index is varchar, text etc type
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' DROP INDEX '.$dropindex.';';
if ($debug) {
$db->debug=999;
}
execute_sql($SQL, $debug);
if ($debug) {
$db->debug=0;
}
} else if ($dropprimary) { //drop primary key
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' DROP PRIMARY KEY;';
if ($debug) {
$db->debug=999;
}
execute_sql($SQL, $debug);
if ($debug) {
$db->debug=0;
}
}
/*********************************
* Change column encoding 2 phase*
*********************************/
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGBLOB';
/*
if ($length > 0) {
$SQL.='('.$length.') ';
}
$SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
*/
if ($debug) {
$db->debug=999;
}
if ($fieldname != 'dummy') {
execute_sql($SQL, $debug);
}
if ($debug) {
$db->debug=0;
}
}
$patterns[]='/RECORDID/'; //for preg_replace $patterns[]='/RECORDID/'; //for preg_replace
$patterns[]='/\{\$CFG\-\>prefix\}/i'; //same here $patterns[]='/\{\$CFG\-\>prefix\}/i'; //same here
@ -483,34 +533,17 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
********************/ ********************/
if ($CFG->dbtype == 'mysql') { if ($CFG->dbtype == 'mysql') {
if ($dropindex){ //drop index if index is varchar, text etc type
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' DROP INDEX '.$dropindex.';';
if ($debug) {
$db->debug=999;
}
execute_sql($SQL, $debug);
if ($debug) {
$db->debug=0;
}
} else if ($dropprimary) { //drop primary key
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename.' DROP PRIMARY KEY;';
if ($debug) {
$db->debug=999;
}
execute_sql($SQL, $debug);
if ($debug) {
$db->debug=0;
}
}
/********************************* /*********************************
* Change column encoding 2 phase* * Change column encoding 2 phase*
*********************************/ *********************************/
/*
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename; $SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' '.$type; $SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGTEXT';
if ($length > 0) { // if ($length > 0) {
$SQL.='('.$length.') '; // $SQL.='('.$length.') ';
} // }
$SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';'; $SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
if ($debug) { if ($debug) {
$db->debug=999; $db->debug=999;
@ -520,7 +553,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
} }
if ($debug) { if ($debug) {
$db->debug=0; $db->debug=0;
} }*/
//phase 2 //phase 2
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename; $SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' '.$type; $SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' '.$type;