[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/station/catalog/ -> station_catalog.install (source)

   1  <?php
   2  
   3  // $Id: station_catalog.install,v 1.16 2009/09/22 20:11:55 drewish Exp $
   4  
   5  /**
   6   * Implementation of hook_schema().
   7   */
   8  function station_catalog_install() {
   9    drupal_install_schema('station_catalog');
  10  }
  11  
  12  /**
  13   * Implementation of hook_uninstall().
  14   */
  15  function station_catalog_uninstall() {
  16    drupal_uninstall_schema('station_catalog');
  17  
  18    if ($vid = variable_get('station_catalog_vocabulary', FALSE)) {
  19      taxonomy_del_vocabulary($vid);
  20    }
  21    variable_del('station_catalog_vocabulary');
  22  }
  23  
  24  /**
  25   * Implementation of hook_schema().
  26   */
  27  function station_catalog_schema() {
  28    $schema['station_catalog'] = array(
  29      'description' => t('Information about albums in the station catalog.'),
  30      'fields' => array(
  31        'nid' => array(
  32          'description' => t("The album's {node}.nid."),
  33          'type' => 'int',
  34          'unsigned' => TRUE,
  35          'not null' => TRUE,
  36          'default' => 0,
  37        ),
  38        'number' => array(
  39          'description' => t('The catalog number.'),
  40          'type' => 'int',
  41          'unsigned' => TRUE,
  42          'not null' => TRUE,
  43          'default' => 0,
  44        ),
  45        'artist' => array(
  46          'description' => t('Name of the artist.'),
  47          'type' => 'varchar',
  48          'length' => 255,
  49          'not null' => TRUE,
  50          'default' => '',
  51        ),
  52        'album' => array(
  53          'description' => t('Name of the album.'),
  54          'type' => 'varchar',
  55          'length' => 255,
  56          'not null' => TRUE,
  57          'default' => '',
  58        ),
  59        'year' => array(
  60          'description' => t('Year the album was released.'),
  61          'type' => 'int',
  62          'unsigned' => TRUE,
  63          'not null' => TRUE,
  64        ),
  65        'label' => array(
  66          'description' => t('Name of the label that released the album.'),
  67          'type' => 'varchar',
  68          'length' => 255,
  69          'not null' => TRUE,
  70          'default' => '',
  71        ),
  72        'mb_release_id' => array(
  73          'description' => t('MusicBrainz release id for the album.'),
  74          'type' => 'varchar',
  75          'length' => 36,
  76          'not null' => TRUE,
  77          'default' => '',
  78        ),
  79        'asin' => array(
  80          'description' => t('Amazon product id..'),
  81          'type' => 'varchar',
  82          'length' => 16,
  83          'not null' => TRUE,
  84          'default' => '',
  85        ),
  86      ),
  87      'indexes' => array(
  88        'station_catalog_artist'  => array('artist'),
  89        'station_catalog_album'   => array('album'),
  90        'station_catalog_year'    => array('year'),
  91        'station_catalog_label'   => array('label'),
  92        'mb_release'              => array('mb_release_id'),
  93      ),
  94      'unique keys' => array(
  95        'station_catalog_number' => array('number')
  96      ),
  97      'primary key' => array('nid'),
  98    );
  99  
 100    return $schema;
 101  }
 102  
 103  /**
 104   * Remove the autonumber from the nid column and add a year column.
 105   */
 106  function station_catalog_update_5200() {
 107    $ret = array();
 108    switch ($GLOBALS['db_type']) {
 109      case 'mysql':
 110      case 'mysqli':
 111        $ret[] = update_sql("ALTER TABLE {station_catalog}
 112          MODIFY COLUMN `nid` INTEGER UNSIGNED NOT NULL DEFAULT 0;
 113        ");
 114        $ret[] = update_sql("ALTER TABLE {station_catalog}
 115          ADD COLUMN `year` INTEGER UNSIGNED NOT NULL AFTER `album`,
 116          ADD INDEX station_catalog_year(`year`);
 117        ");
 118      break;
 119    }
 120    return $ret;
 121  }
 122  
 123  /**
 124   * Add MusicBrainz release id field and Amazon ASIN field.
 125   */
 126  function station_catalog_update_5201() {
 127    $ret = array();
 128    switch ($GLOBALS['db_type']) {
 129      case 'mysql':
 130      case 'mysqli':
 131        $ret[] = update_sql("ALTER TABLE {station_catalog}
 132          ADD COLUMN `mb_release_id` VARCHAR(36) NOT NULL DEFAULT '' AFTER `label`,
 133          ADD INDEX mb_release(`mb_release_id`);
 134        ");
 135        $ret[] = update_sql("ALTER TABLE {station_catalog}
 136          ADD COLUMN `asin` varchar(16) NOT NULL default '' AFTER `mb_release_id`;
 137        ");
 138  
 139      break;
 140    }
 141    return $ret;
 142  }
 143  
 144  /**
 145   * Rename some incorrectly named variables.
 146   */
 147  function station_catalog_update_5202() {
 148    if ($val = variable_get('station_category_vocabulary', FALSE)) {
 149      variable_set('station_catalog_vocabulary', $val);
 150    }
 151  
 152    if ($val = variable_get('station_category_redirect_on_add', FALSE)) {
 153      variable_set('station_catalog_redirect_on_add', $val);
 154    }
 155  
 156    variable_del('station_category_vocabulary');
 157    variable_del('station_category_redirect_on_add');
 158  
 159    return array();
 160  }
 161  
 162  /**
 163   * Implementation of hook_update_last_removed().
 164   */
 165  function station_catalog_update_last_removed() {
 166    // We've removed the 5.x-1.x version of the module, including database
 167    // updates. The next update function is 5200.
 168    return 101;
 169  }
 170  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7