computing.install in Drupal Computing 7.2
Same filename and directory in other branches
Drupal Computing installation file.
File
computing.installView source
<?php
/**
* @file
* Drupal Computing installation file.
*/
/**
* Implements hook_schema().
* @see [#1744340] for information about large input/output causes PHP out of memory.
*/
function computing_schema() {
$schema = array();
$schema['computing_record'] = array(
'description' => 'Stores computing record entity.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Unique auto increment computing record id',
),
'application' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 50,
'description' => 'The application that generates/executes a set of commands. Also serves as the bundle field.',
),
'command' => array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
'description' => 'Command to be executed, no parameters',
),
'label' => array(
'type' => 'varchar',
'not null' => FALSE,
'length' => 255,
'description' => 'Human readable text to explain the command to users',
),
'uid' => array(
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
'description' => "FK User's {users}.uid, if any. If no uid, set to null",
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
'description' => 'Unix timestamp this command is created',
),
'changed' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
'description' => 'Unix timestamp this command is updated',
),
// 'language' => array(
// 'description' => 'The language of the entity. Perhaps required by EntityAPI',
// 'type' => 'varchar',
// 'length' => 32,
// 'not null' => TRUE,
// 'default' => '',
// ),
// parameters and results
// if specify "serialize", data is automatically php-serialized before saving to database. see EntityAPIController::load().
'input' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'description' => 'Input parameters for this command. Serialized JSON/PHP object.',
),
'output' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'description' => 'Return results for this command. Serialized JSON/PHP object.',
),
'status' => array(
'type' => 'char',
'length' => 3,
'not null' => FALSE,
'default' => 'RDY',
'description' => 'Status code of the command',
),
'message' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'Human readable message for users about the execution results',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'unsigned' => FALSE,
'description' => 'Similar to the module weight, 0 is normal, small number has higher priority',
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'application' => array(
'application',
),
'priority' => array(
'created',
'changed',
'weight',
),
),
'foreign keys' => array(
'user_uid' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
'application' => array(
'table' => 'computing_application',
'columns' => array(
'application' => 'application',
),
),
),
);
$schema['computing_application'] = array(
'description' => 'Stores computing application entity: the "bundle" entity for computing record.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary key',
),
'application' => array(
'description' => 'Machine-readable name of this computing application type.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
),
'label' => array(
'description' => 'Human-readable name of this computing application type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The weight of this type in relation to others.',
),
'description' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'normal',
'serialize' => FALSE,
'description' => 'Description of the application type.',
),
) + entity_exportable_schema_fields(),
'primary key' => array(
'id',
),
'unique keys' => array(
'type' => array(
'application',
),
),
);
return $schema;
}
/**
* Implements hook_install()
*/
function computing_install() {
// register the default "Computing" application.
$app = computing_application_create_entity(array(
'application' => 'computing',
'label' => 'Default Drupal Computing Application',
'description' => 'Built in default application by the computing module.',
));
$app
->save();
}
/**
* Implements hook_uninstall().
*/
function computing_uninstall() {
// computing, computing_application database tables are uninstalled by default.
// Need to make sure field instances are uninstalled as well.
// Although it seems it is taken care of EntityAPI according to the "model" module,
}
/**
* Rename table.
*/
//function computing_update_7012() {
// db_rename_table('computing', 'computing_record');
//}
Functions
Name![]() |
Description |
---|---|
computing_install | Implements hook_install() |
computing_schema | Implements hook_schema(). |
computing_uninstall | Implements hook_uninstall(). |