You are here

function uc_order_update_6000 in Ubercart 6.2

File

uc_order/uc_order.install, line 609
Install, update and uninstall functions for the uc_order module.

Code

function uc_order_update_6000() {
  $ret = array();

  // Standardize database definitions during upgrade to Drupal 6.
  // ID fields are unsigned, regular-sized ints.
  // "Boolean" flags are unsigned tiny ints.
  // Postgres tables will have the necessary default values, and MySQL
  // doesn't need them, so the schema can just be mismatched for that.
  // Some id columns are already auto-incremented, so we can't remove the
  // primary key beforehand in MySQL. So we add it later for Postgres.
  db_drop_primary_key($ret, 'uc_orders');
  db_drop_index($ret, 'uc_orders', 'uid');
  db_change_field($ret, 'uc_orders', 'order_id', 'order_id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'order_id',
    ),
  ));
  db_change_field($ret, 'uc_orders', 'uid', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ), array(
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
    ),
  ));
  db_change_field($ret, 'uc_orders', 'delivery_first_name', 'delivery_first_name', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_last_name', 'delivery_last_name', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_phone', 'delivery_phone', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_company', 'delivery_company', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_street1', 'delivery_street1', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_street2', 'delivery_street2', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_city', 'delivery_city', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_zone', 'delivery_zone', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'medium',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_orders', 'delivery_postal_code', 'delivery_postal_code', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'delivery_country', 'delivery_country', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'medium',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_orders', 'billing_first_name', 'billing_first_name', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_last_name', 'billing_last_name', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_phone', 'billing_phone', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_company', 'billing_company', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_street1', 'billing_street1', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_street2', 'billing_street2', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_city', 'billing_city', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_zone', 'billing_zone', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'medium',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_orders', 'billing_postal_code', 'billing_postal_code', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_change_field($ret, 'uc_orders', 'billing_country', 'billing_country', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'medium',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_drop_index($ret, 'uc_order_admin_comments', 'order_id');
  db_change_field($ret, 'uc_order_admin_comments', 'comment_id', 'comment_id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  db_change_field($ret, 'uc_order_admin_comments', 'order_id', 'order_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ), array(
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
    ),
  ));
  db_change_field($ret, 'uc_order_admin_comments', 'uid', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_add_primary_key($ret, 'uc_order_admin_comments', array(
      'comment_id',
    ));
  }
  db_drop_index($ret, 'uc_order_comments', 'order_id');
  db_change_field($ret, 'uc_order_comments', 'comment_id', 'comment_id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  db_change_field($ret, 'uc_order_comments', 'order_id', 'order_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ), array(
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
    ),
  ));
  db_change_field($ret, 'uc_order_comments', 'uid', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_add_primary_key($ret, 'uc_order_comments', array(
      'comment_id',
    ));
  }
  db_drop_index($ret, 'uc_order_line_items', 'order_id');
  db_change_field($ret, 'uc_order_line_items', 'line_item_id', 'line_item_id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  db_change_field($ret, 'uc_order_line_items', 'order_id', 'order_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ), array(
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
    ),
  ));
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_add_primary_key($ret, 'uc_order_line_items', array(
      'line_item_id',
    ));
  }
  db_drop_index($ret, 'uc_order_log', 'order_id');
  db_change_field($ret, 'uc_order_log', 'order_log_id', 'order_log_id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  db_change_field($ret, 'uc_order_log', 'order_id', 'order_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ), array(
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
    ),
  ));
  db_change_field($ret, 'uc_order_log', 'uid', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_add_primary_key($ret, 'uc_order_log', array(
      'order_log_id',
    ));
  }
  db_drop_index($ret, 'uc_order_products', 'order_id');
  db_change_field($ret, 'uc_order_products', 'order_product_id', 'order_product_id', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));
  db_change_field($ret, 'uc_order_products', 'order_id', 'order_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ), array(
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
    ),
  ));
  db_change_field($ret, 'uc_order_products', 'nid', 'nid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_order_products', 'qty', 'qty', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'small',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_order_products', 'cost', 'cost', array(
    'type' => 'numeric',
    'precision' => 10,
    'scale' => 2,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_order_products', 'price', 'price', array(
    'type' => 'numeric',
    'precision' => 10,
    'scale' => 2,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_order_products', 'weight', 'weight', array(
    'type' => 'float',
    'not null' => TRUE,
    'default' => 0,
  ));
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_add_primary_key($ret, 'uc_order_products', array(
      'order_product_id',
    ));
  }
  db_change_field($ret, 'uc_order_statuses', 'weight', 'weight', array(
    'type' => 'int',
    'size' => 'small',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'uc_order_statuses', 'locked', 'locked', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
  return $ret;
}