function entity_example_schema
Implements hook_schema().
Related topics
File
-
entity_example/
entity_example.install, line 15
Code
function entity_example_schema() {
$schema = array();
// The name of the table can be any name we choose. However, namespacing the
// table with the module name is best practice.
$schema['entity_example_basic'] = array(
'description' => 'The base table for our basic entity.',
'fields' => array(
'basic_id' => array(
'description' => 'Primary key of the basic entity.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
// If we allow multiple bundles, then the schema must handle that;
// We'll put it in the 'bundle_type' field to avoid confusion with the
// entity type.
'bundle_type' => array(
'description' => 'The bundle type',
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
// Additional properties are just things that are common to all
// entities and don't require field storage.
'item_description' => array(
'description' => 'A description of the item',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp of the entity creation time.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'basic_id',
),
);
return $schema;
}