You are here

function invoice_update_1 in Invoice 6

Implementation of hook_update_N()

Return value

array Array with query results

File

./invoice.install, line 62

Code

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

  // Array to which query results will be added.
  // Update invoice_customers table
  db_add_index($ret, 'invoice_customers', 'cid', array(
    'cid',
  ));
  db_drop_primary_key($ret, 'invoice_customers');
  db_change_field($ret, 'invoice_customers', 'cid', 'cid', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'cid',
    ),
  ));
  db_drop_index($ret, 'invoice_customers', 'cid');
  db_change_field($ret, 'invoice_customers', 'customer_number', 'customer_number', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'invoice_customers', 'company_name', 'company_name', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'firstname', 'firstname', array(
    'type' => 'varchar',
    'length' => 50,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'lastname', 'lastname', array(
    'type' => 'varchar',
    'length' => 50,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'street', 'street', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'building_number', 'building_number', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'zipcode', 'zipcode', array(
    'type' => 'varchar',
    'length' => 10,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'city', 'city', array(
    'type' => 'varchar',
    'length' => 50,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'country', 'country', array(
    'type' => 'varchar',
    'length' => 50,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'coc_number', 'coc_number', array(
    'type' => 'varchar',
    'length' => 25,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'vat_number', 'vat_number', array(
    'type' => 'varchar',
    'length' => 25,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_customers', 'description', 'description', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_drop_index($ret, 'invoice_customers', 'invoice_id');
  db_change_field($ret, 'invoice_customers', 'invoice_id', 'invoice_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_index($ret, 'invoice_customers', 'invoice_id', array(
    'invoice_id',
  ));
  db_add_index($ret, 'invoice_customers', 'customer_number', array(
    'customer_number',
  ));

  // Update invoice_invoices table
  db_add_index($ret, 'invoice_invoices', 'iid', array(
    'iid',
  ));
  db_drop_primary_key($ret, 'invoice_invoices');
  db_change_field($ret, 'invoice_invoices', 'iid', 'iid', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'iid',
    ),
  ));
  db_drop_index($ret, 'invoice_invoices', 'iid');
  db_change_field($ret, 'invoice_invoices', 'description', 'description', array(
    'type' => 'text',
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_invoices', 'tid', 'tid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_index($ret, 'invoice_invoices', 'tid', array(
    'tid',
  ));
  db_change_field($ret, 'invoice_invoices', 'pay_limit', 'pay_limit', array(
    'type' => 'int',
    'size' => 'small',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'invoice_invoices', 'pay_status', 'pay_status', array(
    'type' => 'varchar',
    'length' => 10,
    'not null' => TRUE,
    'default' => 'unpaid',
  ));
  db_drop_field($ret, 'invoice_invoices', 'depricated_created');
  db_drop_index($ret, 'invoice_invoices', 'nid');
  db_change_field($ret, 'invoice_invoices', 'nid', 'nid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_unique_key($ret, 'invoice_invoices', 'nid', array(
    'nid',
  ));
  db_drop_index($ret, 'invoice_invoices', 'uid');
  db_change_field($ret, 'invoice_invoices', 'uid', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
  ));
  db_add_index($ret, 'invoice_invoices', 'uid', array(
    'uid',
  ));

  // Update invoice_items table
  db_add_index($ret, 'invoice_items', 'iid', array(
    'iid',
  ));
  db_drop_primary_key($ret, 'invoice_items');
  db_change_field($ret, 'invoice_items', 'iid', 'iid', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'iid',
    ),
  ));
  db_drop_index($ret, 'invoice_items', 'iid');
  db_change_field($ret, 'invoice_items', 'description', 'description', array(
    'type' => 'text',
    'size' => 'medium',
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_items', 'unitcost', 'unitcost', array(
    'type' => 'float',
    'size' => 'big',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'invoice_items', 'vat', 'vat', array(
    'type' => 'float',
    'size' => 'big',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'invoice_items', 'weight', 'weight', array(
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_drop_index($ret, 'invoice_items', 'uid');
  db_change_field($ret, 'invoice_items', 'uid', 'uid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => FALSE,
  ));
  db_add_index($ret, 'invoice_items', 'uid', array(
    'uid',
  ));
  db_change_field($ret, 'invoice_items', 'created', 'created', array(
    'type' => 'datetime',
    'not null' => TRUE,
  ));
  db_drop_index($ret, 'invoice_items', 'invoice_id');
  db_change_field($ret, 'invoice_items', 'invoice_id', 'invoice_id', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_index($ret, 'invoice_items', 'invoice_id', array(
    'invoice_id',
  ));

  // Update invoice_templates table
  db_add_index($ret, 'invoice_templates', 'tid', array(
    'tid',
  ));
  db_drop_primary_key($ret, 'invoice_templates');
  db_change_field($ret, 'invoice_templates', 'tid', 'tid', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'tid',
    ),
  ));
  db_drop_index($ret, 'invoice_templates', 'tid');
  db_drop_unique_key($ret, 'invoice_templates', 'name');
  db_change_field($ret, 'invoice_templates', 'name', 'name', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_add_unique_key($ret, 'invoice_templates', 'name', array(
    'name',
  ));
  db_change_field($ret, 'invoice_templates', 'locale', 'locale', array(
    'type' => 'varchar',
    'length' => '25',
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'date_format', 'date_format', array(
    'type' => 'varchar',
    'length' => 50,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'vat', 'vat', array(
    'type' => 'float',
    'size' => 'big',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'invoice_templates', 'pay_limit', 'pay_limit', array(
    'type' => 'int',
    'size' => 'small',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_company_name', 'supplier_company_name', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_street', 'supplier_street', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_building_number', 'supplier_building_number', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_zipcode', 'supplier_zipcode', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_city', 'supplier_city', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_country', 'supplier_country', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_phone', 'supplier_phone', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_fax', 'supplier_fax', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_email', 'supplier_email', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_web', 'supplier_web', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_coc_number', 'supplier_coc_number', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  db_change_field($ret, 'invoice_templates', 'supplier_vat_number', 'supplier_vat_number', array(
    'type' => 'varchar',
    'length' => 100,
    'not null' => FALSE,
  ));
  return $ret;

  // Array with query results.
}