Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. user.install

function user_schema

Implements hook_schema().

File

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

Code

function user_schema() : array {
    $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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal