You are here

function computing_schema in Drupal Computing 7.2

Same name and namespace in other branches
  1. 7 computing.install \computing_schema()

Implements hook_schema().

See also

[#1744340] for information about large input/output causes PHP out of memory.

File

./computing.install, line 12
Drupal Computing installation file.

Code

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;
}