View source
<?php
module_load_include('inc', 'uuid', 'uuid.entity');
function commerce_uuid_schema_alter(&$schema = array()) {
$field = uuid_schema_field_definition();
if (module_exists('commerce_bundle_item')) {
if (isset($schema['commerce_bundle_item'])) {
$schema['commerce_bundle_item']['fields']['uuid'] = $field;
}
}
if (isset($schema['commerce_customer_profile'])) {
$schema['commerce_customer_profile']['fields']['uuid'] = $field;
$schema['commerce_customer_profile_revision']['fields']['vuuid'] = $field;
}
if (isset($schema['commerce_line_item'])) {
$schema['commerce_line_item']['fields']['uuid'] = $field;
}
if (isset($schema['commerce_order'])) {
$schema['commerce_order']['fields']['uuid'] = $field;
$schema['commerce_order_revision']['fields']['vuuid'] = $field;
}
if (isset($schema['commerce_payment_transaction'])) {
$schema['commerce_payment_transaction']['fields']['uuid'] = $field;
$schema['commerce_payment_transaction_revision']['fields']['vuuid'] = $field;
}
if (isset($schema['commerce_product'])) {
$schema['commerce_product']['fields']['uuid'] = $field;
$schema['commerce_product_revision']['fields']['vuuid'] = $field;
}
}
function commerce_uuid_install() {
$field = uuid_schema_field_definition();
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',
));
}
}
}
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',
));
}
}
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',
));
}
}
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',
));
}
}
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',
));
}
}
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();
}
function commerce_uuid_uninstall() {
if (module_exists('commerce_bundle_item')) {
if (db_table_exists('commerce_bundle_item')) {
if (!db_field_exists('commerce_bundle_item', 'uuid')) {
db_drop_field('commerce_bundle_item', 'uuid', $field);
db_drop_index('commerce_bundle_item', 'uuid', array(
'uuid',
));
}
}
}
if (db_table_exists('commerce_customer_profile')) {
if (db_field_exists('commerce_customer_profile', 'uuid')) {
db_drop_field('commerce_customer_profile', 'uuid');
db_drop_index('commerce_customer_profile', 'uuid');
}
if (db_field_exists('commerce_customer_profile_revision', 'vuuid')) {
db_drop_field('commerce_customer_profile_revision', 'vuuid');
db_drop_index('commerce_customer_profile_revision', 'vuuid');
}
}
if (db_table_exists('commerce_line_item')) {
if (db_field_exists('commerce_line_item', 'uuid')) {
db_drop_field('commerce_line_item', 'uuid');
db_drop_index('commerce_line_item', 'uuid');
}
}
if (db_table_exists('commerce_order')) {
if (db_field_exists('commerce_order', 'uuid')) {
db_drop_field('commerce_order', 'uuid');
db_drop_index('commerce_order', 'uuid');
}
if (db_field_exists('commerce_order_revision', 'vuuid')) {
db_drop_field('commerce_order_revision', 'vuuid');
db_drop_index('commerce_order_revision', 'vuuid');
}
}
if (db_table_exists('commerce_payment_transaction')) {
if (db_field_exists('commerce_payment_transaction', 'uuid')) {
db_drop_field('commerce_payment_transaction', 'uuid');
db_drop_index('commerce_payment_transaction', 'uuid');
}
if (db_field_exists('commerce_payment_transaction_revision', 'vuuid')) {
db_drop_field('commerce_payment_transaction_revision', 'vuuid');
db_drop_index('commerce_payment_transaction_revision', 'vuuid');
}
}
if (db_table_exists('commerce_product')) {
if (db_field_exists('commerce_product', 'uuid')) {
db_drop_field('commerce_product', 'uuid');
db_drop_index('commerce_product', 'uuid');
}
if (db_field_exists('commerce_product_revision', 'vuuid')) {
db_drop_field('commerce_product_revision', 'vuuid');
db_drop_index('commerce_product_revision', 'vuuid');
}
}
}
function commerce_uuid_update_7000() {
$commerce_uuid_modules = array(
'commerce_uuid_customer',
'commerce_uuid_line_item',
'commerce_uuid_order',
'commerce_uuid_payment',
'commerce_uuid_product',
);
db_delete('system')
->condition('type', 'module')
->condition('name', $commerce_uuid_modules, 'IN')
->execute();
}