diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php index 3ab85bfdfa..9b43be0144 100644 --- a/core/lib/Drupal/Core/Database/database.api.php +++ b/core/lib/Drupal/Core/Database/database.api.php @@ -249,17 +249,14 @@ * The following keys are defined: * - 'description': A string in non-markup plain text describing this table * and its purpose. References to other tables should be enclosed in - * curly-brackets. For example, the node_field_revision table - * description field might contain "Stores per-revision title and - * body data for each {node}." + * curly-brackets. * - 'fields': An associative array ('fieldname' => specification) * that describes the table's database columns. The specification * is also an array. The following specification parameters are defined: * - 'description': A string in non-markup plain text describing this field * and its purpose. References to other tables should be enclosed in - * curly-brackets. For example, the node table vid field - * description might contain "Always holds the largest (most - * recent) {node_field_revision}.vid value for this nid." + * curly-brackets. For example, the users_data table uid field + * description might contain "Primary key: {users}.uid for user." * - 'type': The generic datatype: 'char', 'varchar', 'text', 'blob', 'int', * 'float', 'numeric', or 'serial'. Most types just map to the according * database engine specific data types. Use 'serial' for auto incrementing @@ -492,60 +489,56 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que * @ingroup schemaapi */ function hook_schema() { - $schema['node'] = [ - // Example (partial) specification for table "node". - 'description' => 'The base table for nodes.', + $schema['users_data'] = [ + 'description' => 'Stores module data as key/value pairs per user.', 'fields' => [ - 'nid' => [ - 'description' => 'The primary identifier for a node.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ], - 'vid' => [ - 'description' => 'The current {node_field_revision}.vid version identifier.', + 'uid' => [ + 'description' => 'Primary key: {users}.uid for user.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ], - 'type' => [ - 'description' => 'The type of this node.', - 'type' => 'varchar', - 'length' => 32, + 'module' => [ + 'description' => 'The name of the module declaring the variable.', + 'type' => 'varchar_ascii', + 'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, 'not null' => TRUE, 'default' => '', ], - 'title' => [ - 'description' => 'The node title.', - 'type' => 'varchar', - 'length' => 255, + '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' => [ - 'node_changed' => ['changed'], - 'node_created' => ['created'], - ], - 'unique keys' => [ - 'nid_vid' => ['nid', 'vid'], - 'vid' => ['vid'], + 'module' => ['module'], + 'name' => ['name'], ], // For documentation purposes only; foreign keys are not created in the // database. 'foreign keys' => [ - 'node_revision' => [ - 'table' => 'node_field_revision', - 'columns' => ['vid' => 'vid'], - ], - 'node_author' => [ - 'table' => 'users', - 'columns' => ['uid' => 'uid'], - ], + 'uid' => ['users' => 'uid'], ], - 'primary key' => ['nid'], ]; + return $schema; }