You are here

function uc_order_update_1 in Ubercart 5

File

uc_order/uc_order.install, line 242

Code

function uc_order_update_1() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {uc_orders} CHANGE delivery_zip delivery_postal_code VARCHAR(10) CHARACTER SET utf8 NOT NULL");
      $ret[] = update_sql("ALTER TABLE {uc_orders} CHANGE billing_zip billing_postal_code VARCHAR(10) CHARACTER SET utf8 NOT NULL");
      break;
    case 'pgsql':
      db_change_column($ret, 'uc_orders', 'delivery_zip', 'delivery_postal_code', 'varchar(10) CHARACTER SET utf8', array(
        'not null' => true,
        'default' => "''",
      ));
      db_change_column($ret, 'uc_orders', 'billing_zip', 'billing_postal_code', 'varchar(10) CHARACTER SET utf8', array(
        'not null' => true,
        'default' => "''",
      ));
      break;
  }
  $result = db_query("SELECT order_id FROM {uc_orders} ORDER BY order_id DESC LIMIT 1");
  if ($data = db_fetch_object($result)) {
    $result = db_query("INSERT INTO {sequences} (name, id) VALUES ('{uc_orders}_order_id', %d)", $data->order_id);
    $ret[] = array(
      'success' => $result !== false,
      'query' => "INSERT INTO {sequences} (name, id) VALUES ('{uc_orders}_order_id'. " . $data->order_id . ")",
    );
  }
  return $ret;
}