You are here

function uc_product_update_7 in Ubercart 5

File

uc_product/uc_product.install, line 237
Database installation, uninstallation, and updates for the product module.

Code

function uc_product_update_7() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {uc_products} CHANGE units weight_units varchar(255) NOT NULL default 'lb'");
      $ret[] = update_sql("ALTER TABLE {uc_products} ADD length float unsigned NOT NULL default 0 AFTER weight_units");
      $ret[] = update_sql("ALTER TABLE {uc_products} ADD width float unsigned NOT NULL default 0 AFTER length");
      $ret[] = update_sql("ALTER TABLE {uc_products} ADD height float unsigned NOT NULL default 0 AFTER width");
      $ret[] = update_sql("ALTER TABLE {uc_products} ADD length_units varchar(255) NOT NULL default 'in' AFTER height");
      $ret[] = update_sql("ALTER TABLE {uc_products} ADD pkg_qty smallint unsigned NOT NULL default 1 AFTER length_units");
      break;
    case 'pgsql':
      db_change_column($ret, 'uc_products', 'units', 'weight_units', 'varchar(255)', array(
        'not null' => true,
        'default' => 'lb',
      ));
      db_add_column($ret, 'uc_products', 'pkg_qty', 'smallint unsigned', array(
        'not null' => true,
        'default' => 1,
      ));
      db_add_column($ret, 'uc_products', 'length', 'float unsigned', array(
        'not null' => true,
        'default' => 0,
      ));
      db_add_column($ret, 'uc_products', 'width', 'float unsigned', array(
        'not null' => true,
        'default' => 0,
      ));
      db_add_column($ret, 'uc_products', 'height', 'float unsigned', array(
        'not null' => true,
        'default' => 0,
      ));
      db_add_column($ret, 'uc_products', 'length_units', 'varchar(255)', array(
        'not null' => true,
        'default' => 'in',
      ));
      break;
  }
  return $ret;
}