You are here

biblio_pm.install in Bibliography Module 7

Database table creation for biblio_pm module.

File

modules/pubmed/biblio_pm.install
View source
<?php

/**
 * @file
 * Database table creation for biblio_pm module.
 */

/**
 * Implementation of hook_install().
 */
function biblio_pm_install() {
}

/**
 *
 */
function biblio_pm_uninstall() {
  variable_del('biblio_pm_dup_action');
  variable_del('biblio_pm_auto_update');
  variable_del('biblio_pm_update_interval');
  variable_del('biblio_pm_update_limit');
  variable_del('biblio_pm_age_limit');
  variable_del('biblio_pm_update_next_execution');
}

/**
 *
 */
function biblio_pm_enable() {
  biblio_pm_set_system_weight();
}

/**
 *
 */
function biblio_pm_set_system_weight() {
  db_update('system')
    ->fields(array(
    'weight' => 19,
  ))
    ->condition('name', 'biblio_pm')
    ->execute();
}

/**
 * Implementation of hook_schema().
 *
 * Note:  Pro Drupal Development models use of t() to translate 'description'
 * for field definitions, but Drupal core does not use them.  We follow core.
 */
function biblio_pm_schema() {
  $schema = array();
  $schema['biblio_pubmed'] = array(
    'fields' => array(
      'biblio_pubmed_id' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'biblio_pmcid' => array(
        'type' => 'varchar',
        'length' => 20,
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'biblio_pubmed_md5' => array(
        'type' => 'char',
        'length' => 32,
        'not null' => TRUE,
      ),
      'biblio_pm_changed' => array(
        'description' => 'The Unix timestamp when the pmid was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  $schema['biblio_pubmed_grant_info'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'biblio_pubmed_id' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'grantid' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
      'acronym' => array(
        'type' => 'varchar',
        'length' => 2,
      ),
      'agency' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
      'country' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

/**
 * UPDATES.
 */

/**
 * Add two new fields to the biblio_pubmed table.
 */
function biblio_pm_update_7001() {
  $spec = array(
    'description' => 'The Unix timestamp when the pmid was most recently saved.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
  db_add_field('biblio_pubmed', 'biblio_pm_changed', $spec);
  $spec = array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
  db_add_field('biblio_pubmed', 'biblio_pmcid', $spec);
}

/**
 * Change field type for biblio_pmcid field to the biblio_pubmed table.
 */
function biblio_pm_update_7002() {
  $spec = array(
    'type' => 'varchar',
    'length' => 20,
    'not null' => FALSE,
  );
  db_change_field('biblio_pubmed', 'biblio_pmcid', 'biblio_pmcid', $spec);
}

/**
 * Add a new table 'biblio_pubmed_grant_info'.
 */
function biblio_pm_update_7004() {
  $schema = biblio_pm_schema();
  $spec = $schema['biblio_pubmed_grant_info'];
  db_create_table('biblio_pubmed_grant_info', $spec);
}

Functions

Namesort descending Description
biblio_pm_enable
biblio_pm_install Implementation of hook_install().
biblio_pm_schema Implementation of hook_schema().
biblio_pm_set_system_weight
biblio_pm_uninstall
biblio_pm_update_7001 Add two new fields to the biblio_pubmed table.
biblio_pm_update_7002 Change field type for biblio_pmcid field to the biblio_pubmed table.
biblio_pm_update_7004 Add a new table 'biblio_pubmed_grant_info'.