function uc_attribute_update_1 in Ubercart 5
File
- uc_attribute/
uc_attribute.install, line 146
Code
function uc_attribute_update_1() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {uc_attributes} CHANGE name name varchar(255) NOT NULL");
$ret[] = update_sql("ALTER TABLE {uc_attributes_options} CHANGE name name varchar(255) NOT NULL");
$ret[] = update_sql("RENAME TABLE {uc_attributes_options} TO {uc_attribute_options}");
$ret[] = update_sql("ALTER TABLE {uc_product_adjustments} CHANGE model model varchar(255) NOT NULL");
$ret[] = update_sql("CREATE TABLE IF NOT EXISTS {uc_class_attributes} (\n `pcid` mediumint(9) NOT NULL,\n `aid` mediumint(9) NOT NULL,\n `default_option` mediumint(9) NOT NULL default '0',\n PRIMARY KEY (`pcid`, `aid`)\n );");
$ret[] = update_sql("CREATE TABLE IF NOT EXISTS {uc_class_attribute_options} (\n `pcid` mediumint(9) NOT NULL,\n `oid` mediumint(9) NOT NULL,\n `price` decimal(10,2) NOT NULL,\n `weight` float NOT NULL,\n PRIMARY KEY (`pcid`,`oid`)\n );");
break;
case 'pgsql':
db_change_column($ret, 'uc_attributes', 'name', 'name', 'varchar(255)', array(
'not null' => true,
'default' => "''",
));
db_change_column($ret, 'uc_attributes_options', 'name', 'name', 'varchar(255)', array(
'not null' => true,
'default' => "''",
));
$ret[] = update_sql("ALTER TABLE {uc_attributes_options} RENAME TO {uc_attribute_options}");
db_change_column($ret, 'uc_product_adjustments', 'model', 'model', 'varchar(255)', array(
'not null' => true,
'default' => "''",
));
$ret[] = update_sql("CREATE TABLE IF NOT EXISTS {uc_class_attributes} (\n pcid integer NOT NULL default '0',\n aid integer NOT NULL '0',\n default_option integer NOT NULL default '0',\n PRIMARY KEY (pcid, aid)\n );");
$ret[] = update_sql("CREATE TABLE IF NOT EXISTS {uc_class_attribute_options} (\n pcid integer NOT NULL default '0',\n oid integer NOT NULL default '0',\n price decimal(10,2) NOT NULL,\n weight float NOT NULL,\n PRIMARY KEY (pcid,oid)\n );");
break;
}
return $ret;
}