function tabledrag_example_schema

Same name in other branches
  1. 3.x modules/tabledrag_example/tabledrag_example.install \tabledrag_example_schema()
  2. 7.x-1.x tabledrag_example/tabledrag_example.install \tabledrag_example_schema()

Implements hook_schema().

This defines the database table which will hold the example item info.

Related topics

File

modules/tabledrag_example/tabledrag_example.install, line 20

Code

function tabledrag_example_schema() {
    $schema['tabledrag_example'] = [
        'description' => 'Stores some entries for our tabledrag fun.',
        'fields' => [
            'id' => [
                'description' => 'The primary identifier for each item',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ],
            'name' => [
                'description' => 'A name for this item',
                'type' => 'varchar',
                'length' => 32,
                'not null' => TRUE,
                'default' => '',
            ],
            'description' => [
                'description' => 'A description for this item',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ],
            'itemgroup' => [
                'description' => 'The group this item belongs to',
                'type' => 'varchar',
                'length' => 32,
                'not null' => TRUE,
                'default' => '',
            ],
            'weight' => [
                'description' => 'The sortable weight for this item',
                'type' => 'int',
                'length' => 11,
                'not null' => TRUE,
                'default' => 0,
            ],
            'pid' => [
                'description' => 'The primary id of the parent for this item',
                'type' => 'int',
                'length' => 11,
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
        ],
        'primary key' => [
            'id',
        ],
    ];
    return $schema;
}