username-1.0.x-dev/username.install
username.install
<?php
/**
* @file
* Contains install and update functions for Username.
*/
use Drupal\Core\Url;
/**
* Implements hook_schema().
*/
function username_schema() {
$schema['user__names'] = [
'description' => 'Stores computed usernames to reduce overhead.',
'fields' => [
'uid' => [
'description' => 'The user ID, linked to the user table.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'name' => [
'description' => 'The generated username.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'created' => [
'description' => 'The UNIX timestamp when the username was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
],
'primary key' => ['uid'],
'indexes' => [
'name' => ['name'],
],
'foreign keys' => [
'users' => [
'table' => 'users',
'columns' => ['uid' => 'uid'],
],
],
];
return $schema;
}
/**
* Implements hook_install().
*/
function username_install() {
// Add a status message with a link to the username settings.
\Drupal::messenger()->addStatus(t('Thank you for installing the Username module. Please check the <a href=":settings">Username settings</a> configuration.', [
':settings' => Url::fromRoute('username.admin_form')->toString(),
]));
}
