/[drupal]/contributions/modules/audio/audio_images.install
ViewVC logotype

Diff of /contributions/modules/audio/audio_images.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.6 by drewish, Wed Mar 7 23:52:01 2007 UTC revision 1.7 by drewish, Sun May 25 17:21:26 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: audio_images.install,v 1.5 2007/01/19 23:45:59 drewish Exp $  // $Id: audio_images.install,v 1.6 2007/03/07 23:52:01 drewish Exp $
3    
 /**  
  * Install the initial schema.  
  */  
4  function audio_images_install() {  function audio_images_install() {
5    switch ($GLOBALS['db_type']) {    drupal_install_schema('audio_images');
     case 'mysql':  
     case 'mysqli':  
       db_query("  
         CREATE TABLE {audio_image} (  
           `pid` int(10) NOT NULL default '0',  
           `nid` int(10) unsigned NOT NULL default '0',  
           `vid` int(10) unsigned NOT NULL default '0',  
           `pictype` tinyint(2) unsigned NOT NULL default '0',  
           `width` smallint(6) unsigned NOT NULL default '0',  
           `height` smallint(6) unsigned NOT NULL default '0',  
           `filemime` varchar(20) NOT NULL default '',  
           `filepath` varchar(255) NOT NULL default '',  
           `filesize` int(10) unsigned NOT NULL default '0',  
           PRIMARY KEY  (`pid`),  
           KEY `audio_image_vid_pictype` (`vid`,`pictype`)  
         ) /*!40100 DEFAULT CHARACTER SET utf8 */;  
       ");  
       break;  
     case 'pgsql':  
       db_query("  
         CREATE TABLE {audio_image} (  
           pid INTEGER PRIMARY KEY,  
           nid INTEGER NOT NULL DEFAULT 0,  
           vid INTEGER NOT NULL DEFAULT 0,  
           pictype INTEGER NOT NULL DEFAULT 0,  
           width INTEGER NOT NULL DEFAULT 0,  
           height INTEGER NOT NULL DEFAULT 0,  
           filemime VARCHAR(20) NOT NULL DEFAULT '',  
           filepath VARCHAR(255) NOT NULL DEFAULT '',  
           filesize INTEGER NOT NULL DEFAULT 0  
         );  
         CREATE INDEX audio_image_vid_pictype_index ON {audio_image} (vid, pictype);  
         CREATE SEQUENCE audio_image_pid_seq;  
       ");  
   }  
6  }  }
7    
 /**  
  * Implementation of hook_uninstall().  
  */  
8  function audio_images_uninstall() {  function audio_images_uninstall() {
9    // TODO should we delete the image files too?    drupal_uninstall_schema('audio_images');
   db_query('DROP TABLE {audio_image}');  
   
10    variable_del('audio_default_image_type');    variable_del('audio_default_image_type');
11    variable_del('audio_image_size');    variable_del('audio_image_size');
12      // TODO should we delete the image files too?
13    }
14    
15    /**
16     * Install the initial schema.
17     */
18    function audio_images_schema() {
19      $schema['audio_image'] = array(
20        'description' => t('Associates an image (such as album artwork) with an audio file.'),
21        'fields' => array(
22          'pid' => array(
23            'type' => 'serial',
24            'size' => 'medium',
25            'not null' => TRUE,
26          ),
27          'nid' => array(
28            'type' => 'int',
29            'size' => 'medium',
30            'not null' => TRUE,
31          ),
32          'vid' => array(
33            'type' => 'int',
34            'size' => 'medium',
35            'not null' => TRUE,
36          ),
37          'pictype' => array(
38            'type' => 'int',
39            'size' => 'tiny',
40            'not null' => TRUE,
41            'default' => 0,
42          ),
43          'width' => array(
44            'type' => 'int',
45            'size' => 'small',
46            'not null' => TRUE,
47            'default' => 0,
48          ),
49          'height' => array(
50            'type' => 'int',
51            'size' => 'small',
52            'not null' => TRUE,
53            'default' => 0,
54          ),
55          'filemime' => array(
56            'type' => 'varchar',
57            'length' => 20,
58            'not null' => TRUE,
59            'default' => '',
60          ),
61          'filepath' => array(
62            'type' => 'varchar',
63            'length' => 255,
64            'not null' => TRUE,
65            'default' => '',
66          ),
67          'filesize' => array(
68            'type' => 'int',
69            'size' => 'medium',
70            'not null' => TRUE,
71            'default' => 0,
72          ),
73        ),
74        'primary key' => array('pid'),
75        'indexes' => array(
76          'audio_image_vid_pictype' => array('vid', 'pictype'),
77        ),
78      );
79      return $schema;
80  }  }
81    
82  /**  /**
# Line 59  function audio_images_uninstall() { Line 84  function audio_images_uninstall() {
84   */   */
85  function audio_images_update_1() {  function audio_images_update_1() {
86    $ret = array();    $ret = array();
87    switch ($GLOBALS['db_type']) {  
88      case 'mysql':    db_add_field($ret, 'audio_image', 'nid',
89      case 'mysqli':      array(
90        $ret[] = update_sql(        'type' => 'int',
91  <<<MYSQL_UPDATE        'size' => 'medium',
92          ALTER TABLE {audio_image}        'not null' => TRUE,
93            ADD COLUMN `nid` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `pid`,      )
94            MODIFY COLUMN `pid` INTEGER UNSIGNED NOT NULL DEFAULT 0,    );
95            ADD INDEX `audio_image_vid_pictype`(`vid`, `pictype`);    db_change_field($ret, 'audio_image', 'pid', 'pid',
96  MYSQL_UPDATE      array(
97        );        'type' => 'serial',
98        break;        'size' => 'medium',
99    }        'not null' => TRUE,
100        )
101      );
102      db_add_index($ret, 'audio_image', 'audio_image_vid_pictype', array('vid', 'pictype'));
103    
104    return $ret;    return $ret;
105  }  }
106    
# Line 80  MYSQL_UPDATE Line 109  MYSQL_UPDATE
109   */   */
110  function audio_images_update_2() {  function audio_images_update_2() {
111    $ret = array();    $ret = array();
112    switch ($GLOBALS['db_type']) {    db_change_field($ret, 'audio_image', 'pid', 'pid',
113      case 'pgsql':      array(
114        $ret[] = update_sql("CREATE SEQUENCE audio_image_pid_seq;");        'type' => 'serial',
115        break;        'size' => 'medium',
116    }        'not null' => TRUE,
117        )
118      );
119    return $ret;    return $ret;
120  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.3