You are here

function tabledrag_example_schema in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 tabledrag_example/tabledrag_example.install \tabledrag_example_schema()
  2. 7 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
Install and uninstall functions for the tabledrag example module.

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