function units_schema in Units of Measurement 7
Same name and namespace in other branches
- 7.2 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.',
),
'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',
),
'factor' => array(
'type' => 'float',
'description' => 'Factor multiplying value by which, you will get the same value in SI unit measure or any other standardized unit measure.',
'not null' => TRUE,
'default' => 0.0,
),
'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',
),
'converter' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Name of cTools units converter plugin responsible for converting units in this measure.',
),
'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',
),
),
);
return $schema;
}