You are here

function commerce_uuid_install in Commerce UUID 7

Implements hook_install().

File

./commerce_uuid.install, line 56

Code

function commerce_uuid_install() {
  $field = uuid_schema_field_definition();

  // Add the uuid column for the commerce_bundle_item entity type.
  if (module_exists('commerce_bundle_item')) {
    if (db_table_exists('commerce_bundle_item')) {
      if (!db_field_exists('commerce_bundle_item', 'uuid')) {
        db_add_field('commerce_bundle_item', 'uuid', $field);
        db_add_index('commerce_bundle_item', 'uuid', array(
          'uuid',
        ));
      }
    }
  }

  // Add the uuid column for the commerce_customer_profile entity type.
  if (db_table_exists('commerce_customer_profile')) {
    if (!db_field_exists('commerce_customer_profile', 'uuid')) {
      db_add_field('commerce_customer_profile', 'uuid', $field);
      db_add_index('commerce_customer_profile', 'uuid', array(
        'uuid',
      ));
    }
    if (!db_field_exists('commerce_customer_profile_revision', 'vuuid')) {
      db_add_field('commerce_customer_profile_revision', 'vuuid', $field);
      db_add_index('commerce_customer_profile_revision', 'vuuid', array(
        'vuuid',
      ));
    }
  }

  // Add the uuid column for the commerce_line_item entity type.
  if (db_table_exists('commerce_line_item')) {
    if (!db_field_exists('commerce_line_item', 'uuid')) {
      db_add_field('commerce_line_item', 'uuid', $field);
      db_add_index('commerce_line_item', 'uuid', array(
        'uuid',
      ));
    }
  }

  // Add the uuid column for the commerce_order entity type.
  if (db_table_exists('commerce_order')) {
    if (!db_field_exists('commerce_order', 'uuid')) {
      db_add_field('commerce_order', 'uuid', $field);
      db_add_index('commerce_order', 'uuid', array(
        'uuid',
      ));
    }
    if (!db_field_exists('commerce_order_revision', 'vuuid')) {
      db_add_field('commerce_order_revision', 'vuuid', $field);
      db_add_index('commerce_order_revision', 'vuuid', array(
        'vuuid',
      ));
    }
  }

  // Add the uuid column for the commerce_payment_transaction entity type.
  if (db_table_exists('commerce_payment_transaction')) {
    if (!db_field_exists('commerce_payment_transaction', 'uuid')) {
      db_add_field('commerce_payment_transaction', 'uuid', $field);
      db_add_index('commerce_payment_transaction', 'uuid', array(
        'uuid',
      ));
    }
    if (!db_field_exists('commerce_payment_transaction_revision', 'vuuid')) {
      db_add_field('commerce_payment_transaction_revision', 'vuuid', $field);
      db_add_index('commerce_payment_transaction_revision', 'vuuid', array(
        'vuuid',
      ));
    }
  }

  // Add the uuid column for the commerce_product entity type.
  if (db_table_exists('commerce_product')) {
    if (!db_field_exists('commerce_product', 'uuid')) {
      db_add_field('commerce_product', 'uuid', $field);
      db_add_index('commerce_product', 'uuid', array(
        'uuid',
      ));
    }
    if (!db_field_exists('commerce_product_revision', 'vuuid')) {
      db_add_field('commerce_product_revision', 'vuuid', $field);
      db_add_index('commerce_product_revision', 'vuuid', array(
        'vuuid',
      ));
    }
  }
  uuid_sync_all();
}