sf_prematch.install in Salesforce Suite 7.2
Same filename and directory in other branches
Installs tables needed for sf_prematch module.
File
sf_prematch/sf_prematch.installView source
<?php
// $Id$
/**
* @file
* Installs tables needed for sf_prematch module.
*/
/**
* Implements hook_install().
*/
function sf_prematch_install() {
// TODO The drupal_(un)install_schema functions are called automatically in D7.
// drupal_install_schema('sf_prematch')
}
/**
* Implements hook_uninstall().
*/
function sf_prematch_uninstall() {
// TODO The drupal_(un)install_schema functions are called automatically in D7.
// drupal_uninstall_schema('sf_prematch')
}
/**
* Implements hook_schema().
*/
function sf_prematch_schema() {
$schema['salesforce_prematch'] = array(
'description' => 'Drupal to Salesforce object mapping table for pre-creation ',
'fields' => array(
'name' => array(
'description' => 'Foreign key for salesforce_field_map name',
'type' => 'varchar',
'length' => 64,
),
'primary_field' => array(
'description' => 'Primary field or object name for use in prematching.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'secondary_field' => array(
'description' => 'Secondary field or object name for use in prematching.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
'default' => '',
),
'tertiary_field' => array(
'description' => 'Tertiary field or object name for use in prematching.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
'default' => '',
),
'rule' => array(
'description' => 'Int identifying rule for prematching (based on constants)',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'name',
),
);
return $schema;
}
/**
* @see salesforce_api_update_1
*
*/
function sf_prematch_update_1() {
$ret = array();
if (!db_field_exists('salesforce_field_map', 'name')) {
$ret[] = array(
'success' => FALSE,
'query' => 'N/A',
);
drupal_set_message(t('There are still updates to be run: Update for sf_prematch was not run. Please run update.php again to complete this update.'), 'warning');
}
db_add_column($ret, 'salesforce_prematch', 'name', 'varchar(255)');
$result = db_query('SELECT fieldmap, name FROM {salesforce_field_map}');
while ($row = db_fetch_array($result)) {
$sql = 'UPDATE {salesforce_prematch} SET name = "%s" WHERE fieldmap = %d';
// TODO Please review the conversion of this statement to the D7 database API syntax.
/* db_query($sql, $name, $fieldmap) */
$update_result = db_update('salesforce_prematch')
->fields(array(
'name' => $name,
))
->condition('fieldmap', $fieldmap)
->execute();
$ret[] = array(
'success' => $update_result !== FALSE,
'query' => check_plain($sql),
);
}
db_add_primary_key('salesforce_prematch', 'name', array(
'name',
));
// TODO update_sql has been removed. Use the database API for any schema or data changes.
$ret[] = array();
// hook_update_N() no longer returns a $ret array. Instead, return
// nothing or a translated string indicating the update ran successfully.
// See http://drupal.org/node/224333#update_sql.
return t('TODO Add a descriptive string here to show in the UI.');
}
Functions
Name | Description |
---|---|
sf_prematch_install | Implements hook_install(). |
sf_prematch_schema | Implements hook_schema(). |
sf_prematch_uninstall | Implements hook_uninstall(). |
sf_prematch_update_1 |