View source
<?php
function commerce_addressbook_schema() {
$schema = array();
$schema['commerce_addressbook_defaults'] = array(
'description' => 'Stores addressbook defaults by customer profile type.',
'fields' => array(
'profile_id' => array(
'description' => 'Numeric ID of the customer profile in the local database.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The customer profile type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'description' => 'The {users}.uid that owns this profile-.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'foreign keys' => array(
'profile_id' => array(
'table' => 'commerce_customer_profile',
'columns' => array(
'profile_id' => 'profile_id',
),
),
'uid' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
),
'unique keys' => array(
'uid_type' => array(
'uid',
'type',
),
),
'indexes' => array(
'profile_id' => array(
'profile_id',
),
'uid' => array(
'uid',
),
),
);
return $schema;
}
function commerce_addressbook_update_7200() {
if (!db_table_exists('commerce_addressbook_defaults')) {
db_create_table('commerce_addressbook_defaults', drupal_get_schema_unprocessed('commerce_addressbook', 'commerce_addressbook_defaults'));
commerce_delete_fields('commerce_addressbook_saved_profiles');
return t('Created the commerce_addressbook_defaults table and deleted all saved profile fields.');
}
}
function commerce_addressbook_update_7300() {
if (db_field_exists('commerce_addressbook_defaults', 'cad_id')) {
db_drop_field('commerce_addressbook_defaults', 'cad_id');
db_add_unique_key('commerce_addressbook_defaults', 'uid_type', array(
'uid',
'type',
));
db_change_field('commerce_addressbook_defaults', 'profile_id', 'profile_id', array(
'description' => 'Numeric ID of the customer profile in the local database.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
), array(
'profile_id' => array(
'profile_id',
),
));
}
}