function dblog_schema

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

Implements hook_schema().

File

core/modules/dblog/dblog.install, line 21

Code

function dblog_schema() : Schema {
  $tables[] = new Table(name: 'watchdog', description: 'Table that contains logs of all system events.', columns: [
    Column::serial(name: 'wid', description: 'Primary Key: Unique watchdog event ID.', size: ColumnSize::Big),
    Column::int(name: 'uid', description: 'The {users}.uid of the user who triggered the event.', unsigned: TRUE, notNull: TRUE, default: new IntValue(0)),
    Column::varcharAscii(name: 'type', description: 'Type of log message, for example "user" or "page not found."', length: 64, notNull: TRUE, default: new StringValue('')),
    Column::text(name: 'message', description: 'Text of log message to be passed into the t() function.', size: ColumnSize::Big, notNull: TRUE),
    Column::blob(name: 'variables', description: 'Serialized array of variables that match the message string and that is passed into the t() function.', size: ColumnSize::Big, notNull: TRUE),
    Column::int(name: 'severity', description: 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)', size: ColumnSize::Tiny, unsigned: TRUE, notNull: TRUE, default: new IntValue(0)),
    Column::text(name: 'link', description: 'Link to view the result of the event.', notNull: FALSE),
    Column::text(name: 'location', description: 'URL of the origin of the event.', notNull: TRUE),
    Column::text(name: 'referer', description: 'URL of referring page.', notNull: FALSE),
    Column::varcharAscii(name: 'hostname', description: 'Hostname of the user who triggered the event.', length: 128, notNull: TRUE, default: new StringValue('')),
    Column::int(name: 'timestamp', description: 'Unix timestamp of when event occurred.', size: ColumnSize::Big, notNull: TRUE, default: new IntValue(0)),
  ], primaryKey: new PrimaryKey([
    'wid',
  ]), indexes: [
    new Index(name: 'type', columns: [
      'type',
    ]),
    new Index(name: 'uid', columns: [
      'uid',
    ]),
    new Index(name: 'severity', columns: [
      'severity',
    ]),
  ]);
  return new Schema(type: SchemaDefinitionType::Module, name: 'dblog', tables: $tables);
}

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