function uc_product_update_8 in Ubercart 5
File
- uc_product/
uc_product.install, line 261 - Database installation, uninstallation, and updates for the product module.
Code
function uc_product_update_8() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {uc_products} ADD vid mediumint(9) NOT NULL default 0 FIRST");
$ret[] = update_sql("ALTER TABLE {uc_products} DROP PRIMARY KEY");
$result = db_query("SELECT nid, vid FROM {node}");
while ($product = db_fetch_object($result)) {
db_query("UPDATE {uc_products} SET vid = %d WHERE nid = %d", $product->vid, $product->nid);
}
$ret[] = update_sql("ALTER TABLE {uc_products} ADD PRIMARY KEY (vid)");
break;
case 'pgsql':
db_add_column($ret, 'uc_products', 'vid', 'integer', array(
'not null' => true,
'default' => 0,
));
$ret[] = update_sql("ALTER TABLE {uc_products} DROP CONSTRAINT {uc_products}_pkey");
$result = db_query("SELECT nid, vid FROM {node}");
while ($product = db_fetch_object($result)) {
db_query("UPDATE {uc_products} SET vid = %d WHERE nid = %d", $product->vid, $product->nid);
}
$ret[] = update_sql("ALTER TABLE {uc_products} ADD PRIMARY KEY (vid)");
break;
}
return $ret;
}