1.20.x user.install | user_schema() |
Implements hook_schema().
File
- modules/
user/ user.install, line 10 - Install, update and uninstall functions for the user module.
Code
function user_schema() {
// The table name here is plural, despite Backdrop table naming standards,
// because "user" is a reserved word in many databases.
$schema['users'] = array(
'description' => 'Stores user data.',
'fields' => array(
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique user ID.',
'default' => 0,
),
'name' => array(
'type' => 'varchar',
'length' => 60,
'not null' => TRUE,
'default' => '',
'description' => 'Unique user name.',
),
'pass' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => "User's password (hashed).",
),
'mail' => array(
'type' => 'varchar',
'length' => 254,
'not null' => FALSE,
'default' => '',
'description' => "User's e-mail address.",
),
'signature' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => "User's signature.",
),
'signature_format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the signature.',
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Timestamp for when user was created.',
),
'access' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Timestamp for previous time user accessed the site.',
),
'login' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "Timestamp for user's last login.",
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Whether the user is active(1) or blocked(0).',
),
'timezone' => array(
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'description' => "User's time zone.",
),
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => "User's default language.",
),
'picture' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "Foreign key: {file_managed}.fid of user's picture.",
),
'init' => array(
'type' => 'varchar',
'length' => 254,
'not null' => FALSE,
'default' => '',
'description' => 'E-mail address used for initial account creation.',
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Backdrop.',
),
),
'indexes' => array(
'access' => array('access'),
'created' => array('created'),
'mail' => array('mail'),
'picture' => array('picture'),
),
'unique keys' => array(
'name' => array('name'),
),
'primary key' => array('uid'),
);
$schema['users_roles'] = array(
'description' => 'Maps users to roles.',
'fields' => array(
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: {users}.uid for user.',
),
'role' => array(
'type' => 'varchar',
'length' => 64,
'description' => 'Primary Key: The name of the role.',
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('uid', 'role'),
'indexes' => array(
'role' => array('role'),
),
'foreign keys' => array(
'user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
$cache_schema = backdrop_get_schema_unprocessed('system', 'cache');
$schema['cache_entity_user'] = $cache_schema;
$schema['cache_entity_user']['description'] = "Cache table used to store Users entity records.";
return $schema;
}