function user_schema

Same name and namespace in other branches
  1. 7.x modules/user/user.install \user_schema()
  2. 9 core/modules/user/user.install \user_schema()
  3. 8.9.x core/modules/user/user.install \user_schema()
  4. 10 core/modules/user/user.install \user_schema()

Implements hook_schema().

File

core/modules/user/user.install, line 11

Code

function user_schema() {
    $schema['users_data'] = [
        'description' => 'Stores module data as key/value pairs per user.',
        'fields' => [
            'uid' => [
                'description' => 'The {users}.uid this record affects.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'module' => [
                'description' => 'The name of the module declaring the variable.',
                'type' => 'varchar_ascii',
                'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
                'not null' => TRUE,
                'default' => '',
            ],
            'name' => [
                'description' => 'The identifier of the data.',
                'type' => 'varchar_ascii',
                'length' => 128,
                'not null' => TRUE,
                'default' => '',
            ],
            'value' => [
                'description' => 'The value.',
                'type' => 'blob',
                'not null' => FALSE,
                'size' => 'big',
            ],
            'serialized' => [
                'description' => 'Whether value is serialized.',
                'type' => 'int',
                'size' => 'tiny',
                'unsigned' => TRUE,
                'default' => 0,
            ],
        ],
        'primary key' => [
            'uid',
            'module',
            'name',
        ],
        'indexes' => [
            'module' => [
                'module',
            ],
            'name' => [
                'name',
            ],
        ],
        'foreign keys' => [
            'data_user' => [
                'table' => 'users',
                'columns' => [
                    'uid' => 'uid',
                ],
            ],
        ],
    ];
    return $schema;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.