function units_schema in Units of Measurement 7.2
Same name and namespace in other branches
- 7 units.install \units_schema()
Implements hook_schema().
File
- ./
units.install, line 11 - Install and uninstall hooks of the Units module.
Code
function units_schema() {
$schema = array();
$schema['units_unit'] = array(
'description' => 'Store information on unit types.',
'fields' => array(
'umid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique unit measure ID.',
),
'measure' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => '{units_measure}.measure that this unit measure is capable of measuring.',
),
'machine_name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Machine readable name of unit measure.',
),
'decomposition_mathematical_expression_id' => array(
'type' => 'int',
'length' => 10,
'not null' => TRUE,
'description' => 'Pointer to {units_mathematical_expression_postfix}.mathematical_expression_id that denotes decomposition of this unit.',
),
'label' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Human readable name of unit measure.',
),
'symbol' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Symbol that corresponds to this unit measure.',
'default' => '',
),
'description' => array(
'description' => 'Description of measure.',
'type' => 'text',
'size' => 'medium',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x1,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array(
'umid',
),
'foreign keys' => array(
'units_measure' => array(
'table' => 'units_measure',
'columns' => array(
'measure' => 'measure',
),
),
),
'unique keys' => array(
'machine_name' => array(
'machine_name',
),
),
);
$schema['units_measure'] = array(
'description' => 'Store information on measures.',
'fields' => array(
'mid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique measure ID.',
),
'measure' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Machine readable name of measure.',
),
'label' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Human readable name of measure.',
),
'description' => array(
'description' => 'Description of measure.',
'type' => 'text',
'size' => 'medium',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
// Set the default to ENTITY_CUSTOM without using the constant as it is
// not safe to use it at this point.
'default' => 0x1,
'size' => 'tiny',
'description' => 'The exportable status of the entity.',
),
'module' => array(
'description' => 'The name of the providing module if the entity has been defined in code.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
'primary key' => array(
'mid',
),
'unique keys' => array(
'measure' => array(
'measure',
),
),
);
$schema['units_mathematical_expression_postfix'] = array(
'description' => 'Store mathematical expressions in postfix (reverse polish notation).',
'fields' => array(
'eid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary key: unique expression ID.',
),
'mathematical_expression_id' => array(
'type' => 'int',
'length' => 10,
'not null' => TRUE,
'unsigned' => TRUE,
'description' => 'ID of the mathematical expression to this this member/token belongs.',
),
'type' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'size' => 'tiny',
'description' => 'Type of this node in abstract tree. ' . UNITS_TOKEN_TYPE_CONSTANT . ' is constant. ' . UNITS_TOKEN_TYPE_UNIT . ' is unit. ' . UNITS_TOKEN_TYPE_OPERATOR . ' is operator.',
),
'value_numeric' => array(
'type' => 'float',
'not null' => TRUE,
'default' => 0,
'description' => 'Numeric value of this node, if numeric value for this node makes sense.',
),
'value_string' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'postfix_order' => array(
'type' => 'int',
'length' => 10,
'not null' => TRUE,
'unsigned' => TRUE,
'description' => 'Order of this member/token in its mathematical expression.',
),
),
'primary key' => array(
'eid',
),
);
return $schema;
}