/[drupal]/contributions/modules/geshifilter/geshinode.install
ViewVC logotype

Contents of /contributions/modules/geshifilter/geshinode.install

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


Revision 1.5 - (show annotations) (download) (as text)
Mon Jul 6 22:45:53 2009 UTC (4 months, 3 weeks ago) by soxofaan
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +33 -6 lines
File MIME type: text/x-php
#363770 by Scott Reynolds and Soxofaan: fix revision issues in the database schema for geshinode (with upgrade path)
1 <?php
2 // $Id: geshinode.install,v 1.4 2008/07/21 17:44:23 soxofaan Exp $
3
4 /**
5 * @file
6 * Installation and uninstallation functions for the GeSHi node module.
7 */
8
9 /**
10 * Implementation of hook_schema()
11 */
12 function geshinode_schema() {
13 $schema['geshinode'] = array(
14 'description' => t('The table for geshinodes.'),
15 'fields' => array(
16 'nid' => array(
17 'description' => t('The primary identifier for a node.'),
18 'type' => 'int',
19 'unsigned' => TRUE,
20 'not null' => TRUE,
21 ),
22 'vid' => array(
23 'description' => t('The current {node_revisions}.vid version identifier.'),
24 'type' => 'int',
25 'unsigned' => TRUE,
26 'not null' => TRUE,
27 'default' => 0,
28 ),
29 'language' => array(
30 'description' => t('The source code language of the node.'),
31 'type' => 'varchar',
32 'length' => 64,
33 'not null' => TRUE,
34 'default' => '',
35 ),
36 ),
37 'primary key' => array('vid'),
38 'indexes' => array('nid' => array('nid')),
39 );
40 return $schema;
41 }
42
43 /**
44 * Create tables on install
45 */
46 function geshinode_install() {
47 // Create geshinode tables.
48 drupal_install_schema('geshinode');
49 }
50
51 /**
52 * Remove tables on uninstall.
53 */
54 function geshinode_uninstall() {
55 // Drop geshinode tables.
56 drupal_uninstall_schema('geshinode');
57 }
58
59
60 /**
61 * Implementation of hook_update_N().
62 *
63 * Fix the primary key and indices on the geshinode table.
64 * See http://drupal.org/node/363770 .
65 */
66 function geshinode_update_6001() {
67 $ret = array();
68 // Drop unique key on 'vid'.
69 db_drop_unique_key($ret, 'geshinode', 'vid');
70 // Change the 'nid' field to 'int' (from 'serial').
71 db_change_field($ret, 'geshinode', 'nid', 'nid',
72 array(
73 'description' => t('The primary identifier for a node.'),
74 'type' => 'int',
75 'unsigned' => TRUE,
76 'not null' => TRUE,
77 )
78 );
79 // Drop primary key ('nid').
80 db_drop_primary_key($ret, 'geshinode');
81 // Add primary key on 'vid'.
82 db_add_primary_key($ret, 'geshinode', array('vid'));
83 // Add an index on 'nid'.
84 db_add_index($ret, 'geshinode', 'nid', array('nid'));
85 return $ret;
86 }

  ViewVC Help
Powered by ViewVC 1.1.2