You are here

simplifying.install in Simplifying 8

File

simplifying.install
View source
<?php

use Drupal\Core\Database\Database;

/**
 * Implements hook_schema().
 */
function simplifying_schema() {
  $schema['simplifying_entity_unread'] = [
    'description' => 'new unread entitis.',
    'fields' => [
      'id' => [
        'description' => 'The primary identifier.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'entity_type' => [
        'description' => 'Entity type',
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
      ],
      'bundle' => [
        'description' => 'Bundle',
        'type' => 'varchar',
        'length' => 100,
        'not null' => FALSE,
      ],
      'entity_id' => [
        'description' => 'Entity ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
      ],
    ],
    'indexes' => [
      'id' => [
        'id',
      ],
      'entity_type' => [
        'entity_type',
      ],
      'bundle' => [
        'bundle',
      ],
      'entity_id' => [
        'entity_id',
      ],
    ],
    'primary key' => [
      'id',
    ],
  ];
  return $schema;
}

/**
 * Create table "simplifying_entity_unread"
 */
function simplifying_update_8001() {
  $schema = Database::getConnection()
    ->schema();
  if (!$schema
    ->tableExists('simplifying_entity_unread')) {
    $specs = simplifying_schema();
    $schema
      ->createTable('simplifying_entity_unread', $specs['simplifying_entity_unread']);
  }
}

Functions

Namesort descending Description
simplifying_schema Implements hook_schema().
simplifying_update_8001 Create table "simplifying_entity_unread"