| 1 |
<?php
|
| 2 |
// $Id: scaffolding_example.install,v 1.3 2008/09/15 21:57:08 davereid Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Scaffolding example module's install and uninstall code.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*
|
| 12 |
* This hook is called the first time the module is installed. Unless it is
|
| 13 |
* explicitly uninstalled, disabling and re-enabling will not trigger this hook
|
| 14 |
* a second time.
|
| 15 |
*/
|
| 16 |
function scaffolding_example_install() {
|
| 17 |
drupal_install_schema('scaffolding_example');
|
| 18 |
}
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Implementation of hook_schema().
|
| 22 |
*
|
| 23 |
* This hook should return a SchemaAPI array with a full definition of the most
|
| 24 |
* up-to-date version of the module's database tables.
|
| 25 |
*/
|
| 26 |
function scaffolding_example_schema() {
|
| 27 |
$schema['scaffolding_record'] = array(
|
| 28 |
'description' => t('Stores custom links to be added to nodes.'),
|
| 29 |
'fields' => array(
|
| 30 |
'record_id' => array(
|
| 31 |
'type' => 'serial',
|
| 32 |
'unsigned' => TRUE,
|
| 33 |
'not null' => TRUE,
|
| 34 |
'description' => t('Unique identifier for the {scaffolding_record}.'),
|
| 35 |
),
|
| 36 |
'title' => array(
|
| 37 |
'type' => 'varchar',
|
| 38 |
'length' => 255,
|
| 39 |
'not null' => TRUE,
|
| 40 |
'default' => '',
|
| 41 |
'description' => t("The visible title of the {scaffolding_record}.")
|
| 42 |
),
|
| 43 |
'content' => array(
|
| 44 |
'type' => 'text',
|
| 45 |
'not null' => FALSE,
|
| 46 |
'size' => 'big',
|
| 47 |
'description' => t('A description of the term.'),
|
| 48 |
),
|
| 49 |
'weight' => array(
|
| 50 |
'type' => 'int',
|
| 51 |
'not null' => TRUE,
|
| 52 |
'default' => 0,
|
| 53 |
'size' => 'tiny',
|
| 54 |
'description' => t('The weight of this {scaffolding_record}.'),
|
| 55 |
),
|
| 56 |
),
|
| 57 |
'primary key' => array('record_id'),
|
| 58 |
);
|
| 59 |
return $schema;
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Implementation of hook_update_N().
|
| 64 |
*
|
| 65 |
* This function is responsible for updating the module's database tables when
|
| 66 |
* a new version requires changes. (For example, if version 1.1 of the module
|
| 67 |
* added a new field to the database).
|
| 68 |
*
|
| 69 |
* The numbers of your module's update functions should follow the pattern
|
| 70 |
* hook_update_XYZZ, where X is the version of Drupal your module is compatible
|
| 71 |
* with, Y is the major version of your module, and ZZ is the number of the
|
| 72 |
* update. For example, the first update for version 1.x of this module would
|
| 73 |
* be numbered 6100, while the first update for the 2.x version of the module
|
| 74 |
* would be numbered 6200. For more details on update numbering conventions,
|
| 75 |
* see http://drupal.org/node/114774#update-n.
|
| 76 |
*
|
| 77 |
* hook_update_N() functions only run when upgrading an already-installed module
|
| 78 |
* to a new version, NOT when initially installing the module.
|
| 79 |
*/
|
| 80 |
function scaffolding_example_update_6100() {
|
| 81 |
$new_column = array(
|
| 82 |
'type' => 'int',
|
| 83 |
'not null' => TRUE,
|
| 84 |
'default' => 0,
|
| 85 |
'size' => 'tiny',
|
| 86 |
'description' => t('The weight of this {scaffolding_record}.'),
|
| 87 |
);
|
| 88 |
|
| 89 |
$ret = array();
|
| 90 |
db_add_field($ret, 'scaffolding_record', 'weight', $new_column);
|
| 91 |
return $ret;
|
| 92 |
}
|
| 93 |
|
| 94 |
/**
|
| 95 |
* Implementation of hook_uninstall().
|
| 96 |
*
|
| 97 |
* This hook is called when the already-disabled module is explicitly uninstalled
|
| 98 |
* by the administrator -- simple disabling the module will trigger hook_disable().
|
| 99 |
* It should delete any database tables added by the module, remove any variables
|
| 100 |
* that are unique to the module, and clear out any cached data.
|
| 101 |
*/
|
| 102 |
function scaffolding_example_uninstall() {
|
| 103 |
drupal_uninstall_schema('scaffolding_example');
|
| 104 |
cache_clear_all('scaffolding_example:*', 'cache', TRUE);
|
| 105 |
variable_del('scaffolding_example_setting');
|
| 106 |
}
|