You are here

function commerce_pricelist_update_7001 in Commerce Pricelist 7

Add list_id field to pricelist item table.

File

./commerce_pricelist.install, line 181
Install for a Commerce Pricelist - create the base tables for our entities.

Code

function commerce_pricelist_update_7001(&$sandbox) {
  if (!db_field_exists('commerce_pricelist_item', 'pricelist_id')) {
    $field = array(
      'type' => 'int',
      'default' => 0,
      'description' => 'The List ID.',
      'not null' => TRUE,
    );
    $keys = array(
      'foreign keys' => array(
        'item_pricelist' => array(
          'table' => 'commerce_pricelist',
          'columns' => array(
            'pricelist_id' => 'list_id',
          ),
        ),
      ),
    );
    db_drop_unique_key('commerce_pricelist_item', 'item_pricelist');
    db_add_field('commerce_pricelist_item', 'pricelist_id', $field, $keys);
    db_add_index('commerce_pricelist_item', 'pricelist_id', array(
      'pricelist_id',
    ));
  }
}