You are here

tacjs.install in TacJS 8.5

Same filename and directory in other branches
  1. 8 tacjs.install
  2. 8.2 tacjs.install

File

tacjs.install
View source
<?php

use Drupal\Core\Database\Database;

/**
 * Creates the tables using the schema API.
 */
function tacjs_schema() {
  $schema['tacjslog'] = [
    'description' => 'The proof of consent.',
    'fields' => [
      'uid' => [
        'description' => 'Primary Key: unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'timestamp' => [
        'description' => 'The Timestamp.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ],
      'ip_address' => [
        'description' => 'The IP address.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'services_allowed' => [
        'description' => 'The service.',
        'type' => 'text',
        'not null' => TRUE,
      ],
    ],
    'primary key' => [
      'uid',
    ],
    'indexes' => [
      'uid' => [
        'uid',
      ],
    ],
  ];
  return $schema;
}

/**
 * Create the tacjslog table
 */
function tacjs_update_8001() {
  $schema = Database::getConnection()
    ->schema();
  if (!$schema
    ->tableExists('tacjslog')) {
    $spec = tacjs_schema()['tacjslog'];
    $schema
      ->createTable('tacjslog', $spec);
  }
}

Functions

Namesort descending Description
tacjs_schema Creates the tables using the schema API.
tacjs_update_8001 Create the tacjslog table