function uc_store_update_2 in Ubercart 5
File
- uc_store/
uc_store.install, line 147
Code
function uc_store_update_2() {
$ret = array();
// Get rid of the auto_increment.
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {uc_zones} CHANGE zone_id zone_id MEDIUMINT(11) NOT NULL");
$ret[] = update_sql("ALTER TABLE {uc_zones} CHANGE zone_name zone_name VARCHAR(255) CHARACTER SET utf8 NOT NULL");
$ret[] = update_sql("ALTER TABLE {uc_countries} CHANGE country_id country_id MEDIUMINT(11) NOT NULL");
break;
case 'pgsql':
db_change_column($ret, 'uc_zones', 'zone_id', 'zone_id', 'integer', array(
'not null' => true,
'default' => 0,
));
db_change_column($ret, 'uc_zones', 'zone_name', 'zone_name', 'varchar(255) CHARACTER SET utf8', array(
'not null' => true,
'default' => "''",
));
db_change_column($ret, 'uc_countries', 'country_id', 'country_id', 'integer', array(
'not null' => true,
'default' => 0,
));
break;
}
// Make the fixes for U.S.
$ret[] = update_sql("UPDATE {uc_countries} SET country_id = 840 WHERE country_id = 223");
$ret[] = update_sql("UPDATE {uc_zones} SET zone_country_id = 840 WHERE zone_country_id = 223");
$ret[] = update_sql("UPDATE {uc_orders} SET delivery_country = 840 WHERE delivery_country = 223");
$ret[] = update_sql("UPDATE {uc_orders} SET billing_country = 840 WHERE billing_country = 223");
if (variable_get('uc_store_country', 223) == 223) {
variable_set('uc_store_country', 840);
}
// Make the fixes for Canada.
$ret[] = update_sql("UPDATE {uc_countries} SET country_id = 124 WHERE country_id = 38");
$ret[] = update_sql("UPDATE {uc_zones} SET zone_country_id = 124 WHERE zone_country_id = 38");
if (variable_get('uc_store_country', 223) == 38) {
variable_set('uc_store_country', 124);
}
$result = db_query("SELECT zone_id FROM {uc_zones} ORDER BY zone_id DESC LIMIT 1");
if ($row = db_fetch_object($result)) {
$max_id = $row->zone_id;
}
else {
$max_id = 1;
}
$ret[] = update_sql("INSERT INTO {sequences} VALUES ('{uc_zones}_zone_id', {$max_id})");
return $ret;
}