sheetnode.install in Sheetnode 7.2
Same filename and directory in other branches
Install, update and uninstall functions for the sheetnode module.
File
sheetnode.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the sheetnode module.
*/
/**
* Implements hook_schema().
*/
function sheetnode_schema() {
return sheetnode_schema_7003();
}
/**
* Schema function.
*/
function sheetnode_schema_7001() {
$schema['sheetnode'] = array(
'description' => 'The base table for sheetnodes.',
'fields' => array(
'nid' => array(
'description' => 'The primary identifier for a node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'description' => 'The revision identifier for a node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'value' => array(
'description' => 'The worksheet content.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
),
'primary key' => array(
'vid',
),
'unique keys' => array(
'nid_vid' => array(
'nid',
'vid',
),
),
'foreign keys' => array(
'node_revision' => array(
'table' => 'node_revision',
'columns' => array(
'vid' => 'vid',
),
),
'node' => array(
'table' => 'node',
'columns' => array(
'nid' => 'nid',
),
),
),
);
$schema['sheetnode_template'] = array(
'description' => 'The table for sheetnode templates.',
'fields' => array(
'tid' => array(
'description' => 'The primary identifier for the template.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => '32',
'default' => '',
'not null' => TRUE,
'description' => 'The unique name of the template.',
),
'value' => array(
'description' => 'The worksheet template content.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
'vid' => array(
'description' => 'The original node version for this template.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
),
'primary key' => array(
'tid',
),
'unique keys' => array(
'name' => array(
'name',
),
'vid' => array(
'vid',
),
),
'foreign keys' => array(
'node_revision' => array(
'table' => 'node_revision',
'columns' => array(
'vid' => 'vid',
),
),
),
);
return $schema;
}
/**
* Schema function.
*/
function sheetnode_schema_7003() {
$schema = sheetnode_schema_7001();
$schema['sheetnode_view'] = array(
'description' => 'The table for sheetview annotations.',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The primary identifier for the annotation.',
),
'view_name' => array(
'type' => 'varchar',
'length' => '32',
'default' => '',
'not null' => TRUE,
'description' => 'The unique name of the sheetview.',
),
'display_id' => array(
'type' => 'varchar',
'length' => '32',
'default' => '',
'not null' => TRUE,
'description' => 'The display id of the sheetview.',
),
'value' => array(
'description' => 'The sheetview annotation content.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
),
'primary key' => array(
'id',
),
'unique_keys' => array(
'view_name_display' => array(
'view_name',
'display_id',
),
),
);
return $schema;
}
/**
* Implements hook_field_schema().
*/
function sheetnode_field_schema($field) {
return sheetnode_field_schema_7002($field);
}
/**
* Schema function.
*/
function sheetnode_field_schema_7001($field) {
$columns = array(
'value' => array(
'description' => 'The worksheet content.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
);
$indexes = array();
return array(
'columns' => $columns,
'indexes' => $indexes,
);
}
/**
* Schema function.
*/
function sheetnode_field_schema_7002($field) {
$columns = array(
'value' => array(
'description' => 'The worksheet content.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
'name' => array(
'description' => 'The worksheet title.',
'type' => 'varchar',
'length' => '100',
'not null' => TRUE,
'default' => '',
),
);
$indexes = array(
'name' => array(
'name',
),
);
return array(
'columns' => $columns,
'indexes' => $indexes,
);
}
/**
* Implements hook_update_N().
*
* Add 'name' field to sheetfields.
*/
function sheetnode_update_7002(&$sandbox) {
// @see http://drupal.stackexchange.com/questions/30301/update-field-schema
$fields = field_info_fields();
foreach ($fields as $field_name => $field) {
if ($field['type'] == 'sheetfield' && $field['storage']['type'] == 'field_sql_storage') {
$schema = sheetnode_field_schema_7002($field);
foreach ($field['storage']['details']['sql'] as $type => $table_info) {
foreach ($table_info as $table_name => $columns) {
$column_name = _field_sql_storage_columnname($field_name, 'name');
db_add_field($table_name, $column_name, $schema['columns']['name']);
db_add_index($table_name, $column_name, array(
$column_name,
));
}
}
}
}
field_cache_clear();
}
/**
* Implements hook_update_N().
*
* Add 'sheetnode_view' table.
*/
function sheetnode_update_7003(&$sandbox) {
$schema = sheetnode_schema_7003();
db_create_table('sheetnode_view', $schema['sheetnode_view']);
}
Functions
Name | Description |
---|---|
sheetnode_field_schema | Implements hook_field_schema(). |
sheetnode_field_schema_7001 | Schema function. |
sheetnode_field_schema_7002 | Schema function. |
sheetnode_schema | Implements hook_schema(). |
sheetnode_schema_7001 | Schema function. |
sheetnode_schema_7003 | Schema function. |
sheetnode_update_7002 | Implements hook_update_N(). |
sheetnode_update_7003 | Implements hook_update_N(). |